public void GivenGame_WhenRunWithGoldenMasterInput_ThenOutputIsTheSameAsGoldenMasterOutput() { using (var istrm = new FileStream("Input.txt", FileMode.Open, FileAccess.Read)) using (var gstrm = new FileStream("GoldenMaster.txt", FileMode.Open, FileAccess.Read)) using (var input = new StreamReader(istrm)) using (var goldenMaster = new StreamReader(gstrm)) using (var output = new StringWriter()) { var @out = Console.Out; Console.SetOut(output); var values = input.ReadToEnd().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse); var randomizer = new RandomStub(values); for (var i = 0; i < 5000; i++) { GameRunner.Run(randomizer); Console.WriteLine("Exiting " + randomizer.Count + Environment.NewLine); } var runOutput = output.ToString(); File.WriteAllText("Output.txt", runOutput); Console.SetOut(@out); Assert.That(runOutput, Is.EqualTo(goldenMaster.ReadToEnd())); } }
//[Test] public void GenerateGoldenMaster() { //"C:\\Users\\mpantea\\AppData\\Local\\JetBrains\\Installations\\ReSharperPlatformVs15_23e94da4\\Output.txt" Console.WriteLine(Path.GetFullPath("GoldenMaster.txt")); using (var istrm = new FileStream("Input.txt", FileMode.Open, FileAccess.Read)) using (var ostrm = new FileStream("GoldenMaster.txt", FileMode.OpenOrCreate, FileAccess.Write)) using (var reader = new StreamReader(istrm)) using (var writer = new StreamWriter(ostrm)) { Console.SetOut(writer); var values = reader.ReadToEnd().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse); var randomizer = new RandomStub(values); for (var i = 0; i < 5000; i++) { GameRunner.Run(randomizer); Console.WriteLine("Exiting " + randomizer.Count + Environment.NewLine); } } }