Permalink
Browse files

Add golden master test WalkthroughTest for Game

  • Loading branch information...
bobbymcr committed Nov 26, 2018
1 parent ab561f8 commit dc580dce5bfca7349c9d28c5d1f5824872b28f58

This file was deleted.

Oops, something went wrong.
@@ -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);
}
}
}
@@ -10,7 +10,7 @@ internal static class Program
{
private static void Main()
{
Console.WriteLine(new Derived("Hello world").Text);
new Game(Console.In, Console.Out).Run();
}
}
}
@@ -16,4 +16,12 @@
<ItemGroup>
<ProjectReference Include="..\src\Adventure.App.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="walkthrough.in">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="walkthrough.out">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

This file was deleted.

Oops, something went wrong.
@@ -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

Please sign in to comment.