public void LabTest() { IField lab = new Labyrinth(7); var expected = 7; var actual = lab.Size; Assert.AreEqual(expected, actual); }
public Engine(Labyrinth labyrinth) { this.sizeOfTheLabirynth = labyrinth.Size; this.startPositionX = this.sizeOfTheLabirynth / 2; this.startPositionY = this.sizeOfTheLabirynth / 2; this.labyrinth = labyrinth; this.scoreBoard = new ScoreBoard(); this.player = new Player(this.startPositionX, this.startPositionY); this.IntroduceTheGame(); }
public void RemoveObjectTest() { IField lab = new Labyrinth(7); lab.RemoveObject(new Coords(3, 3)); var expected = '-'; var actual = lab[3, 3]; Assert.AreEqual(expected, actual); }
public void AddObjectTest() { IField lab = new Labyrinth(7); GameObject obj = new GameObject('$', 3, 3); lab.AddObject(obj); var expected = '$'; var actual = lab[3, 3]; Assert.AreEqual(expected, actual); }
public void PrintLabyrithTest() { char[,] staticLabyrinth = { { '-', '-', 'X', 'X', 'X', 'X', '-' }, { '-', 'X', '-', '-', '-', '-', 'X' }, { '-', 'X', '-', 'X', 'X', '-', 'X' }, { '-', 'X', '-', '*', 'X', '-', 'X' }, { '-', 'X', '-', 'X', '-', '-', '-' }, { '-', 'X', '-', '-', '-', 'X', 'X' }, { 'X', '-', 'X', '-', '-', 'X', 'X' } }; Labyrinth labyrinth = new Labyrinth(7); for (int i = 0; i < labyrinth.Size; i++) { for (int j = 0; j < labyrinth.Size; j++) { labyrinth[i, j] = staticLabyrinth[i, j]; } } using (var sw = new StringWriter()) { Console.SetOut(sw); labyrinth.PrintLabirynth(); StringBuilder actual = new StringBuilder(); string[] splitLines = sw.ToString().TrimEnd().Split('\r', '\n'); for (int i = 0; i < splitLines.Length; i++) { if (!string.IsNullOrWhiteSpace(splitLines[i])) { actual.AppendLine(splitLines[i]); } } StringBuilder expected = new StringBuilder(); for (int i = 0; i < staticLabyrinth.GetLength(0); i++) { for (int j = 0; j < staticLabyrinth.GetLength(1); j++) { expected.AppendFormat("{0,2}", staticLabyrinth[i, j].ToString()); } expected.AppendLine(); } Assert.AreEqual(expected.ToString(), actual.ToString()); } }
public Engine(int sizeOfTheLabirynth) { if (sizeOfTheLabirynth < 1) { throw new ArgumentException("The size of the labyrinth cannot be less than 1", "sizeOfTheLabyrinth"); } this.sizeOfTheLabirynth = sizeOfTheLabirynth; this.startPositionX = sizeOfTheLabirynth / 2; this.startPositionY = sizeOfTheLabirynth / 2; this.labyrinth = new Labyrinth(sizeOfTheLabirynth); this.scoreBoard = new ScoreBoard(); this.player = new Player(this.startPositionX, this.startPositionY); this.IntroduceTheGame(); }
public void RenderTest() { Labyrinth lab = new Labyrinth(4); char[,] testMatrix = new char[,] { {'-', 'X', '-', 'X'}, {'-', '-', '-', 'X'}, {'X', 'X', '-', '-'} , {'X', 'X', '-', '-'} }; lab.TestMatrix(testMatrix); ConsoleRenderer renderer = new ConsoleRenderer(); var actual = renderer.Render(lab); var expected = " - X - X\r\n - - - X\r\n X X - -\r\n X X - -\r\n"; Assert.AreEqual(expected, actual); }
public void AddObjectFailTest() { Labyrinth lab = new Labyrinth(7); GameObject obj = new GameObject('$', 0, 1); char[,] testMatrix = new char[,] { {'-', 'X', '-', 'X'}, {'-', '-', '-', 'X'}, {'X', 'X', '-', '-'} , {'X', 'X', '-', '-'} }; lab.TestMatrix(testMatrix); lab.AddObject(obj); var expected = 'X'; var actual = lab[0, 1]; Assert.AreEqual(expected, actual); }
public void CreateLabyrinthZeroDimentions() { Labyrinth lab = new Labyrinth(0); }
public void CreateLabyrinthTest() { Labyrinth labyrinth = new Labyrinth(1); Assert.AreEqual(1, labyrinth.Size); }
public void CreateLabyrinthNegativeDimentions() { Labyrinth lab = new Labyrinth(-1); }
public void AccessLabyrinthTest() { Labyrinth labyrinth = new Labyrinth(5); labyrinth[labyrinth.Size, labyrinth.Size] = '2'; }
public void ConstructorTestArgumentIsNotZero() { Labyrinth lab = new Labyrinth(0); int a = lab.Size; }
public void ConstructorTesArgumnetIsNotNegative() { Labyrinth lab = new Labyrinth(-1); int a = lab.Size; }
private void ExecuteCommand(string command) { switch (command.ToUpper()) { case "L": { this.Move(0, -1); break; } case "R": { this.Move(0, 1); break; } case "U": { this.Move(-1, 0); break; } case "D": { this.Move(1, 0); break; } case "RESTART": { this.player = new Player(this.startPositionX, this.startPositionY); this.labyrinth = new Labyrinth(this.sizeOfTheLabirynth); break; } case "TOP": { this.scoreBoard.PrintScore(); break; } case "EXIT": { break; } default: { this.PrintInvalidInput(); break; } } }