public void PatternConstructorPositive() { Simulator simulator; bool[,] generation; simulator = new Simulator(CommonPattern.Blinker); generation = simulator.GetCurrentGeneration(); Assert.IsNotNull(generation, "Generation is null"); Assert.IsTrue((generation.GetLength(0) == 5) && (generation.GetLength(1) == 5), "Rows and Columns lengths is not 5"); Assert.IsTrue(generation[1, 2] && generation[2, 2] && generation[3, 2], "First generation does not have right live cells"); }
public void BoolConstructorPositive() { Simulator simulator; bool[,] generation; bool[,] seed = new bool[2, 2]; seed[1, 1] = true; simulator = new Simulator(seed); generation = simulator.GetCurrentGeneration(); Assert.IsNotNull(generation, "Generation is null"); Assert.IsTrue((generation.GetLength(0) == seed.GetLength(0)) && (generation.GetLength(1) == seed.GetLength(1)) , "generation and seed do not have same dimension"); for (int x = 0; x < seed.GetLength(0); x++) { for (int y = 0; y < seed.GetLength(1); y++) { if (seed[x, y] != generation[x, y]) { Assert.Fail("Generation and seed cell are nor equal"); break; } } } }
public void StepPositive() { Simulator simulator; CommonPattern seedPattern = CommonPattern.Pulsar; simulator = new Simulator(seedPattern); var firstGeneration = simulator.GetCurrentGeneration(); simulator.Step(); simulator.Step(); simulator.Step(); var thirdGeneration = simulator.GetCurrentGeneration(); Assert.IsTrue((firstGeneration.GetLength(0) == thirdGeneration.GetLength(0)) && (firstGeneration.GetLength(1) == thirdGeneration.GetLength(1)), "First and third generations dimension are not equal"); for (int x = 0; x < firstGeneration.GetLength(0); x++) { for (int y = 0; y < firstGeneration.GetLength(1); y++) { if (firstGeneration[x, y] != thirdGeneration[x, y]) { Assert.Fail("First Generation and Third Generation are not same."); break; } } } }
public void StringConstructorPositive() { Simulator simulator; string seed = "1,1|2,2|3,3"; simulator = new Simulator(seed); var generation = simulator.GetCurrentGeneration(); Assert.IsNotNull(generation, "Generation is null"); Assert.IsTrue(generation.GetLength(0) == 5 && generation.GetLength(1) == 5,"Invalid dimensions for first genearation array"); Assert.IsTrue(generation[1,1] && generation[2,2] && generation[3,3],"First genration has incorrect live cells"); }