public void ComposeUnits_ComposesPromotionTreeViaPromotionTreeComposer() { var treeOne = BuildPromotionTree(); var treeTwo = BuildPromotionTree(); var treeThree = BuildPromotionTree(); BuildUnit(BuildHexCell(new HexCoordinates(0, 1)), BuildCivilization(), BuildUnitTemplate(), treeOne); BuildUnit(BuildHexCell(new HexCoordinates(2, 3)), BuildCivilization(), BuildUnitTemplate(), treeTwo); BuildUnit(BuildHexCell(new HexCoordinates(4, 5)), BuildCivilization(), BuildUnitTemplate(), treeThree); var serialTreeOne = new SerializablePromotionTreeData(); var serialTreeTwo = new SerializablePromotionTreeData(); var serialTreeThree = new SerializablePromotionTreeData(); MockPromotionTreeComposer.Setup(composer => composer.ComposePromotionTree(treeOne)).Returns(serialTreeOne); MockPromotionTreeComposer.Setup(composer => composer.ComposePromotionTree(treeTwo)).Returns(serialTreeTwo); MockPromotionTreeComposer.Setup(composer => composer.ComposePromotionTree(treeThree)).Returns(serialTreeThree); var unitComposer = Container.Resolve <UnitComposer>(); var mapData = new SerializableMapData(); unitComposer.ComposeUnits(mapData); Assert.AreEqual(serialTreeOne, mapData.Units[0].PromotionTree, "Unexpected PromotionTree value in data representing unitOne"); Assert.AreEqual(serialTreeTwo, mapData.Units[1].PromotionTree, "Unexpected PromotionTree value in data representing unitTwo"); Assert.AreEqual(serialTreeThree, mapData.Units[2].PromotionTree, "Unexpected PromotionTree value in data representing unitThree"); }
public void DecomposePromotionTree_ConstructsOnProperTemplateAndChosenPromotions() { BuildPromotionTemplate("Template One"); var templateTwo = BuildPromotionTemplate("Template Two"); var promotionOne = BuildPromotion("Promotion One"); var promotionTwo = BuildPromotion("Promotion Two"); var promotionThree = BuildPromotion("Promotion Three"); BuildPromotion("Promotion Four"); var serialTree = new SerializablePromotionTreeData() { Template = "Template Two", ChosenPromotions = new List <string>() { "Promotion One", "Promotion Two", "Promotion Three" } }; var composer = Container.Resolve <PromotionTreeComposer>(); var promotionTree = composer.DecomposePromotionTree(serialTree); Assert.AreEqual(templateTwo, promotionTree.Template, "PromotionTree has an unexpected template"); CollectionAssert.AreEquivalent( new List <IPromotion>() { promotionOne, promotionTwo, promotionThree }, promotionTree.GetChosenPromotions(), "PromotionTree has an unexpected collection of chosen promotions" ); }
public void DecomposeUnits_PromotionTreesDecomposedProperly() { BuildHexCell(new HexCoordinates(1, 1)); BuildHexCell(new HexCoordinates(2, 2)); BuildCivilization("Civ One"); BuildCivilization("Civ Two"); BuildUnitTemplate("Template One"); BuildUnitTemplate("Template Two"); var serialTreeOne = new SerializablePromotionTreeData(); var serialTreeTwo = new SerializablePromotionTreeData(); var treeOne = BuildPromotionTree(); var treeTwo = BuildPromotionTree(); MockPromotionTreeComposer.Setup(composer => composer.DecomposePromotionTree(serialTreeOne)).Returns(treeOne); MockPromotionTreeComposer.Setup(composer => composer.DecomposePromotionTree(serialTreeTwo)).Returns(treeTwo); var mapData = new SerializableMapData() { Units = new List <SerializableUnitData>() { new SerializableUnitData() { Location = new HexCoordinates(1, 1), Owner = "Civ One", Template = "Template One", PromotionTree = serialTreeOne }, new SerializableUnitData() { Location = new HexCoordinates(2, 2), Owner = "Civ Two", Template = "Template Two", PromotionTree = serialTreeTwo } } }; var unitComposer = Container.Resolve <UnitComposer>(); unitComposer.DecomposeUnits(mapData); Assert.AreEqual(treeOne, AllUnits[0].PromotionTree, "The first instantiated unit has an unexpected PromotionTree value"); Assert.AreEqual(treeTwo, AllUnits[1].PromotionTree, "The second instantiated unit has an unexpected PromotionTree value"); }