public void Constructor_WhenInvoked_PreparesEmptyPatternCorrectly() { // act var empty = new Empty(); int oneSide = empty.GetPattern().Length; int otherSide = empty.GetPattern().Max(x => x.Length); // assert Assert.IsTrue( oneSide == 1 && oneSide == otherSide, message: "The empty pattern was not of size 1x1."); Assert.IsTrue( empty.IsStable, message: "The empty pattern was not stable."); Assert.AreEqual( expected: 0, actual: empty.StabilizesAt, message: "The empty pattern stabilizes at the wrong time."); Assert.AreEqual( expected: 0, actual: empty.StablePopulation, message: "The empty pattern has wrong number of cells in the stable population."); }
/// <summary> /// Builds a new life form. /// </summary> /// <param name="lifeFormType">The life form type to build.</param> /// <returns>A newly instantiated life form object.</returns> public static LifeFormBase Build(LifeForm lifeFormType) { LifeFormBase lifeForm = null; switch (lifeFormType) { case LifeForm.Empty: lifeForm = new Empty(); break; case LifeForm.Acorn: lifeForm = new Acorn(); break; case LifeForm.AircraftCarrier: lifeForm = new AircraftCarrier(); break; case LifeForm.FivePoint: lifeForm = new FivePoint(); break; default: lifeForm = new RandomPattern( rows: RANDOMPATTERNHEIGHT, cols: RANDOMPATTERNWIDTH); break; } return lifeForm; }