Permalink
Please sign in to comment.
Showing
with
73 additions
and 33 deletions.
- +0 −14 app/src/Derived.cs
- +34 −0 app/src/Game.cs
- +1 −1 app/src/Program.cs
- +8 −0 app/test/Adventure.App.Test.csproj
- +0 −18 app/test/DerivedTest.cs
- +28 −0 app/test/GameTest.cs
- +1 −0 app/test/walkthrough.in
- +1 −0 app/test/walkthrough.out
@@ -0,0 +1,34 @@ | |||
// <copyright file="Game.cs" company="Brian Rogers"> | |||
// Copyright (c) Brian Rogers. All rights reserved. | |||
// </copyright> | |||
|
|||
namespace Adventure.App | |||
{ | |||
using System.IO; | |||
|
|||
public sealed class Game | |||
{ | |||
private readonly TextReader reader; | |||
private readonly TextWriter writer; | |||
|
|||
public Game(TextReader reader, TextWriter writer) | |||
{ | |||
this.reader = reader; | |||
this.writer = writer; | |||
} | |||
|
|||
public void Run() | |||
{ | |||
string line; | |||
do | |||
{ | |||
line = this.reader.ReadLine(); | |||
if (line == "hello") | |||
{ | |||
this.writer.WriteLine("world"); | |||
} | |||
} | |||
while (line != null); | |||
} | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
// <copyright file="GameTest.cs" company="Brian Rogers"> | |||
// Copyright (c) Brian Rogers. All rights reserved. | |||
// </copyright> | |||
|
|||
namespace Adventure.App.Test | |||
{ | |||
using System.IO; | |||
using FluentAssertions; | |||
using Xunit; | |||
|
|||
public sealed class GameTest | |||
{ | |||
[Fact] | |||
public void WalkthroughTest() | |||
{ | |||
const string ActualOut = "walkthrough.actual.out"; | |||
const string ExpectedOut = "walkthrough.out"; | |||
|
|||
using (StreamReader reader = new StreamReader("walkthrough.in")) | |||
using (StreamWriter writer = new StreamWriter(ActualOut)) | |||
{ | |||
new Game(reader, writer).Run(); | |||
} | |||
|
|||
File.ReadAllLines(ActualOut).Should().Equal(File.ReadAllLines(ExpectedOut)); | |||
} | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
hello |
@@ -0,0 +1 @@ | |||
world |
0 comments on commit
dc580dc