public void Given_a_random_starting_position_When_the_game_starts_Then_the_correct_lights_are_on() { _consoleMock.Setup(console => console.WriteLine(" |0|1|2|3|4|")).Verifiable("Header not displayed correctly"); _consoleMock.Setup(console => console.WriteLine("0| | | | |*|\r\n1| | | | | |\r\n2| | |*| | |\r\n3| | | | | |\r\n4| | | | | |\r\n")).Verifiable("Light grid not displayed correctly"); _randomMock.Setup(random => random.Next(1, 25)).Returns(2); _randomMock.SetupSequence(random => random.Next(0, 25)).Returns(4).Returns(12); _lights.Initialise(); _lights.Display(); _consoleMock.Verify(); }
public void Run(string[] args) { _console.WriteLine("--- Welcome to the Lights Out game! ---"); _lights.Initialise(); _lights.Display(); _console.WriteLine("Enter q to quit"); while (!_lights.Out()) { _console.WriteLine("Enter row number"); var xInput = _console.ReadLine(); if (_validator.IsQuit(xInput)) { Environment.Exit(0); } if (!_validator.IsValid(xInput, _lights.XMax)) { continue; } int.TryParse(xInput, out var x); _console.WriteLine("Enter column number"); var yInput = _console.ReadLine(); if (_validator.IsQuit(yInput)) { Environment.Exit(0); } if (!_validator.IsValid(yInput, _lights.YMax)) { continue; } int.TryParse(yInput, out var y); _lightController.Press(_lights.LightGrid, _lights.XMax, _lights.YMax, x, y); _lights.Display(); } _console.WriteLine("Congratulations, you have turned out all the lights. You are a winner :)"); }