public void DecomposeImprovements_PassesPrimitivesProperly() { var mapData = new SerializableMapData() { Improvements = new List<SerializableImprovementData>() { new SerializableImprovementData() { Location = new HexCoordinates(0, 0), Template = "Template One", IsConstructed = false, IsPillaged = true, WorkInvested = 10 } } }; BuildImprovementTemplate("Template One"); BuildHexCell(new HexCoordinates(0, 0)); var composer = Container.Resolve<ImprovementComposer>(); composer.DecomposeImprovements(mapData); MockImprovementFactory.Verify( factory => factory.BuildImprovement( It.IsAny<IImprovementTemplate>(), It.IsAny<IHexCell>(), 10, false, true ), Times.Once, "BuildImprovement was not called with the expected primitive arguments" ); }
public void DecomposeCells_FeatureChangedThroughCellModificationLogic() { var mapData = new SerializableMapData() { HexCells = new List <SerializableHexCellData>() { new SerializableHexCellData() { Coordinates = new HexCoordinates(0, 0), Feature = CellFeature.Oasis }, new SerializableHexCellData() { Coordinates = new HexCoordinates(1, 1), Feature = CellFeature.None }, } }; var composer = Container.Resolve <HexCellComposer>(); composer.DecomposeCells(mapData); var cellOne = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(0, 0))).First(); var cellTwo = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(1, 1))).First(); MockCellModificationLogic.Verify( logic => logic.ChangeFeatureOfCell(cellOne, CellFeature.Oasis), Times.Once, "ChangeFeatureOfCell not called properly on cellOne" ); MockCellModificationLogic.Verify( logic => logic.ChangeFeatureOfCell(cellTwo, CellFeature.None), Times.Once, "ChangeFeatureOfCell not called properly on cellTwo" ); }
public void DecomposeCells_HasRoadsChangedThroughCellModificationLogic() { var mapData = new SerializableMapData() { HexCells = new List <SerializableHexCellData>() { new SerializableHexCellData() { Coordinates = new HexCoordinates(0, 0), HasRoads = false }, new SerializableHexCellData() { Coordinates = new HexCoordinates(1, 1), HasRoads = true }, } }; var composer = Container.Resolve <HexCellComposer>(); composer.DecomposeCells(mapData); var cellOne = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(0, 0))).First(); var cellTwo = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(1, 1))).First(); MockCellModificationLogic.Verify( logic => logic.ChangeHasRoadsOfCell(cellOne, false), Times.Once, "ChangeHasRoadsOfCellTo not called properly on cellOne" ); MockCellModificationLogic.Verify( logic => logic.ChangeHasRoadsOfCell(cellTwo, true), Times.Once, "ChangeHasRoadsOfCellTo not called properly on cellTwo" ); }
public void ComposeCells_ShapeRecorded() { var cellOne = BuildHexCell(new HexCoordinates(0, 1)); var cellTwo = BuildHexCell(new HexCoordinates(2, 3)); var cellThree = BuildHexCell(new HexCoordinates(4, 5)); cellOne.Shape = CellShape.Mountains; cellTwo.Shape = CellShape.Flatlands; cellThree.Shape = CellShape.Hills; var composer = Container.Resolve <HexCellComposer>(); var mapData = new SerializableMapData(); composer.ComposeCells(mapData); var dataLikeCellOne = mapData.HexCells.Where( data => data.Coordinates == cellOne.Coordinates && data.Shape == cellOne.Shape ); var dataLikeCellTwo = mapData.HexCells.Where( data => data.Coordinates == cellTwo.Coordinates && data.Shape == cellTwo.Shape ); var dataLikeCellThree = mapData.HexCells.Where( data => data.Coordinates == cellThree.Coordinates && data.Shape == cellThree.Shape ); Assert.AreEqual(1, dataLikeCellOne.Count(), "Unexpected number of data representing CellOne"); Assert.AreEqual(1, dataLikeCellTwo.Count(), "Unexpected number of data representing CellTwo"); Assert.AreEqual(1, dataLikeCellThree.Count(), "Unexpected number of data representing CellThree"); }
public void ComposeCells_HasRoadsRecorded() { var cellOne = BuildHexCell(new HexCoordinates(0, 1)); var cellTwo = BuildHexCell(new HexCoordinates(2, 3)); var cellThree = BuildHexCell(new HexCoordinates(4, 5)); cellOne.HasRoads = true; cellTwo.HasRoads = false; cellThree.HasRoads = false; var composer = Container.Resolve <HexCellComposer>(); var mapData = new SerializableMapData(); composer.ComposeCells(mapData); var dataLikeCellOne = mapData.HexCells.Where( data => data.Coordinates == cellOne.Coordinates && data.HasRoads == cellOne.HasRoads ); var dataLikeCellTwo = mapData.HexCells.Where( data => data.Coordinates == cellTwo.Coordinates && data.HasRoads == cellTwo.HasRoads ); var dataLikeCellThree = mapData.HexCells.Where( data => data.Coordinates == cellThree.Coordinates && data.HasRoads == cellThree.HasRoads ); Assert.AreEqual(1, dataLikeCellOne.Count(), "Unexpected number of data representing CellOne"); Assert.AreEqual(1, dataLikeCellTwo.Count(), "Unexpected number of data representing CellTwo"); Assert.AreEqual(1, dataLikeCellThree.Count(), "Unexpected number of data representing CellThree"); }
public void ComposeUnits_StoresExperienceAndLevel() { var unitOne = BuildUnit(BuildHexCell(new HexCoordinates(0, 1)), BuildCivilization(), BuildUnitTemplate()); var unitTwo = BuildUnit(BuildHexCell(new HexCoordinates(2, 3)), BuildCivilization(), BuildUnitTemplate()); var unitThree = BuildUnit(BuildHexCell(new HexCoordinates(4, 5)), BuildCivilization(), BuildUnitTemplate()); unitOne.Experience = 10; unitTwo.Experience = 20; unitThree.Experience = 30; unitOne.Level = 1; unitTwo.Level = 2; unitThree.Level = 3; var composer = Container.Resolve <UnitComposer>(); var mapData = new SerializableMapData(); composer.ComposeUnits(mapData); Assert.AreEqual(10, mapData.Units[0].Experience, "Unexpected Experience value in data representing unitOne"); Assert.AreEqual(20, mapData.Units[1].Experience, "Unexpected Experience value in data representing unitTwo"); Assert.AreEqual(30, mapData.Units[2].Experience, "Unexpected Experience value in data representing unitThree"); Assert.AreEqual(1, mapData.Units[0].Level, "Unexpected Level value in data representing unitOne"); Assert.AreEqual(2, mapData.Units[1].Level, "Unexpected Level value in data representing unitTwo"); Assert.AreEqual(3, mapData.Units[2].Level, "Unexpected Level value in data representing unitThree"); }
public void DecomposeUnits_SetsHitpointsProperly() { BuildHexCell(new HexCoordinates(1, 1)); BuildHexCell(new HexCoordinates(2, 2)); BuildCivilization("Civ One"); BuildCivilization("Civ Two"); BuildUnitTemplate("Template One"); BuildUnitTemplate("Template Two"); var mapData = new SerializableMapData() { Units = new List <SerializableUnitData>() { new SerializableUnitData() { Location = new HexCoordinates(1, 1), Owner = "Civ One", Template = "Template One", Hitpoints = 5 }, new SerializableUnitData() { Location = new HexCoordinates(2, 2), Owner = "Civ Two", Template = "Template Two", Hitpoints = -2 } } }; var composer = Container.Resolve <UnitComposer>(); composer.DecomposeUnits(mapData); Assert.AreEqual(5, AllUnits[0].CurrentHitpoints, "The first instantiated unit has an unexpected Hitpoints value"); Assert.AreEqual(-2, AllUnits[1].CurrentHitpoints, "The second instantiated unit has an unexpected Hitpoints value"); }
public void ComposeCivilizations_RecordsExploredCells() { var templateOne = BuildCivTemplate("Civ One", Color.black); var civOne = BuildCivilization(templateOne, 1, 10); var exploredCell = BuildCell(new HexCoordinates(1, 1)); var unexploredCell = BuildCell(new HexCoordinates(2, 2)); MockExplorationCanon.Setup(canon => canon.IsCellExploredByCiv(exploredCell, civOne)).Returns(true); MockExplorationCanon.Setup(canon => canon.IsCellExploredByCiv(unexploredCell, civOne)).Returns(false); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); CollectionAssert.AreEquivalent( new List <HexCoordinates>() { new HexCoordinates(1, 1) }, mapData.Civilizations[0].ExploredCells ); }
public void ComposeCivilizations_RecordsGoldenAgeData() { var civOne = BuildCivilization(BuildCivTemplate("", Color.black), 0, 0); var civTwo = BuildCivilization(BuildCivTemplate("", Color.black), 0, 0); MockGoldenAgeCanon.Setup(canon => canon.GetPreviousGoldenAgesForCiv(civOne)).Returns(1); MockGoldenAgeCanon.Setup(canon => canon.GetPreviousGoldenAgesForCiv(civTwo)).Returns(2); MockGoldenAgeCanon.Setup(canon => canon.GetGoldenAgeProgressForCiv(civOne)).Returns(11); MockGoldenAgeCanon.Setup(canon => canon.GetGoldenAgeProgressForCiv(civTwo)).Returns(22); MockGoldenAgeCanon.Setup(canon => canon.GetTurnsLeftOnGoldenAgeForCiv(civOne)).Returns(111); MockGoldenAgeCanon.Setup(canon => canon.GetTurnsLeftOnGoldenAgeForCiv(civTwo)).Returns(222); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); var civDataOne = mapData.Civilizations[0]; var civDataTwo = mapData.Civilizations[1]; Assert.AreEqual(1, civDataOne.PreviousGoldenAges, "CivOne.PreviousGoldenAges not stored correctly"); Assert.AreEqual(2, civDataTwo.PreviousGoldenAges, "CivTwo.PreviousGoldenAges not stored correctly"); Assert.AreEqual(11, civDataOne.GoldenAgeProgress, "CivOne.GoldenAgeProgress not stored correctly"); Assert.AreEqual(22, civDataTwo.GoldenAgeProgress, "CivTwo.GoldenAgeProgress not stored correctly"); Assert.AreEqual(111, civDataOne.GoldenAgeTurnsLeft, "CivOne.GoldenAgeTurnsLeft not stored correctly"); Assert.AreEqual(222, civDataTwo.GoldenAgeTurnsLeft, "CivTwo.GoldenAgeTurnsLeft not stored correctly"); }
public void ComposeCivilizations_RecordsTechQueue() { var templateOne = BuildCivTemplate("Civ One", Color.black); var civOne = BuildCivilization(templateOne, 1, 10); var queuedTechOne = BuildTechDefinition("Queued One"); var queuedTechTwo = BuildTechDefinition("Queued Two"); BuildTechDefinition("Unqueued"); civOne.TechQueue.Enqueue(queuedTechOne); civOne.TechQueue.Enqueue(queuedTechTwo); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); CollectionAssert.AreEqual( new List <string>() { "Queued One", "Queued Two" }, mapData.Civilizations[0].TechQueue, "Serializable civilization data has an unexpected tech queue" ); }
public void ComposeCivilizations_RecordsDiscoveredTechs() { var templateOne = BuildCivTemplate("Civ One", Color.black); var civOne = BuildCivilization(templateOne, 1, 10); var discoveredTechs = new List <ITechDefinition>() { BuildTechDefinition("Discovered One"), BuildTechDefinition("Discovered Two") }; BuildTechDefinition("Undiscovered"); MockTechCanon.Setup(canon => canon.GetTechsDiscoveredByCiv(civOne)).Returns(discoveredTechs); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); CollectionAssert.AreEquivalent( discoveredTechs.Select(tech => tech.Name), mapData.Civilizations[0].DiscoveredTechs, "Serializable civilization data has an unexpected collection of discovered techs" ); }
public void ComposeCivilizations_RecordsIntrinsicCivilizationData() { var templateOne = BuildCivTemplate("Civ One", Color.black); var templateTwo = BuildCivTemplate("Civ Two", Color.white); var civOne = BuildCivilization(templateOne, 1, 10); var civTwo = BuildCivilization(templateTwo, 2, 20); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); var dataLikeCivOne = mapData.Civilizations.Where( civ => civ.TemplateName.Equals(civOne.Template.Name) && civ.GoldStockpile == civOne.GoldStockpile && civ.CultureStockpile == civOne.CultureStockpile ); var dataLikeCivTwo = mapData.Civilizations.Where( civ => civ.TemplateName.Equals(templateTwo.Name) && civ.GoldStockpile == civTwo.GoldStockpile && civ.CultureStockpile == civTwo.CultureStockpile ); Assert.AreEqual(1, dataLikeCivOne.Count(), "Did not find the expected number of serializable civs like civOne"); Assert.AreEqual(1, dataLikeCivTwo.Count(), "Did not find the expected number of serializable civs like civTwo"); }
public void DecomposeResources_PassesPrimitivesProperly() { var mapData = new SerializableMapData() { ResourceNodes = new List <SerializableResourceNodeData>() { new SerializableResourceNodeData() { Location = new HexCoordinates(2, 3), ResourceName = "Resource One", Copies = 5 } } }; BuildResourceDefinition("Resource One"); BuildHexCell(new HexCoordinates(2, 3)); var composer = Container.Resolve <ResourceComposer>(); composer.DecomposeResources(mapData); MockNodeFactory.Verify( factory => factory.BuildNode( It.IsAny <IHexCell>(), It.IsAny <IResourceDefinition>(), 5 ), Times.Once, "NodeFactory.BuildNode was not called with the expected copies argument" ); }
public void ComposeResourcesTests(ComposeResourcesTestData testData) { foreach (var nodeTestData in testData.ResourceNodes) { BuildResourceNode(nodeTestData); } var mapData = new SerializableMapData(); var composer = Container.Resolve <ResourceComposer>(); composer.ComposeResources(mapData); var resultsAsTestData = mapData.ResourceNodes.Select(data => new ResourceNodeTestData() { LocationCoordinates = data.Location, ResourceName = data.ResourceName, Copies = data.Copies }); CollectionAssert.AreEquivalent( testData.ResourceNodes, resultsAsTestData, "The nodes passed in and the nodes placed into MapData are not equivalent sets" ); }
public void DecomposeDiplomacy_AssemblesOngoingDealsThroughOngoingDealComposer() { var serialDealOne = new SerializableOngoingDealData(); var serialDealTwo = new SerializableOngoingDealData(); var serialDealThree = new SerializableOngoingDealData(); var dealOne = BuildOngoingDeal(); var dealTwo = BuildOngoingDeal(); var dealThree = BuildOngoingDeal(); var mapData = new SerializableMapData() { DiplomacyData = new SerializableDiplomacyData() { ActiveOngoingDeals = new List <SerializableOngoingDealData>() { serialDealOne, serialDealTwo, serialDealThree } } }; MockOngoingDealComposer.Setup(composer => composer.DecomposeOngoingDeal(serialDealOne)).Returns(dealOne); MockOngoingDealComposer.Setup(composer => composer.DecomposeOngoingDeal(serialDealTwo)).Returns(dealTwo); MockOngoingDealComposer.Setup(composer => composer.DecomposeOngoingDeal(serialDealThree)).Returns(dealThree); var diplomacyComposer = Container.Resolve <DiplomacyComposer>(); diplomacyComposer.DecomposeDiplomacy(mapData); MockDiplomacyCore.Verify(core => core.SubscribeOngoingDeal(dealOne), Times.Once, "DealOne was never sent"); MockDiplomacyCore.Verify(core => core.SubscribeOngoingDeal(dealTwo), Times.Once, "DealTwo was never sent"); MockDiplomacyCore.Verify(core => core.SubscribeOngoingDeal(dealThree), Times.Once, "DealThree was never sent"); }
public void ComposeCivilizations_RecordsCivDiscovery() { var civOne = BuildCivilization(BuildCivTemplate("Civ One", Color.black), 0, 0); var civTwo = BuildCivilization(BuildCivTemplate("Civ Two", Color.black), 0, 0); var civThree = BuildCivilization(BuildCivTemplate("Civ Three", Color.black), 0, 0); var discoveryPairs = new List <Tuple <ICivilization, ICivilization> >() { new Tuple <ICivilization, ICivilization>(civOne, civTwo), new Tuple <ICivilization, ICivilization>(civOne, civThree), new Tuple <ICivilization, ICivilization>(civTwo, civThree), }; MockCivDiscoveryCanon.Setup(canon => canon.GetDiscoveryPairs()).Returns(discoveryPairs); var mapData = new SerializableMapData(); var composer = Container.Resolve <CivilizationComposer>(); composer.ComposeCivilizations(mapData); var expectedNamePairs = new List <Tuple <string, string> >() { new Tuple <string, string>("Civ One", "Civ Two"), new Tuple <string, string>("Civ One", "Civ Three"), new Tuple <string, string>("Civ Two", "Civ Three"), }; CollectionAssert.AreEquivalent(expectedNamePairs, mapData.CivDiscoveryPairs); }
public void ComposeUnits_StoresLocationsByCoordinates() { BuildUnit(BuildHexCell(new HexCoordinates(0, 1)), BuildCivilization(), BuildUnitTemplate()); BuildUnit(BuildHexCell(new HexCoordinates(2, 3)), BuildCivilization(), BuildUnitTemplate()); BuildUnit(BuildHexCell(new HexCoordinates(4, 5)), BuildCivilization(), BuildUnitTemplate()); var composer = Container.Resolve <UnitComposer>(); var mapData = new SerializableMapData(); composer.ComposeUnits(mapData); var dataLikeUnitOne = mapData.Units.Where(data => data.Location.Equals(new HexCoordinates(0, 1))); var dataLikeUnitTwo = mapData.Units.Where(data => data.Location.Equals(new HexCoordinates(2, 3))); var dataLikeUnitThree = mapData.Units.Where(data => data.Location.Equals(new HexCoordinates(4, 5))); Assert.AreEqual(3, mapData.Units.Count, "Unexpected number of elements in MapData.Units"); Assert.AreEqual( 1, dataLikeUnitOne.Count(), "Unexpected number of elements in MapData.Units with coordinates of UnitOne" ); Assert.AreEqual( 1, dataLikeUnitTwo.Count(), "Unexpected number of elements in MapData.Units with coordinates of UnitTwo" ); Assert.AreEqual( 1, dataLikeUnitThree.Count(), "Unexpected number of elements in MapData.Units with coordinates of UnitThree" ); }
public void DecomposeCivilizations_CallsIntoFactoryWithTemplate() { var mapData = new SerializableMapData() { Civilizations = new List <SerializableCivilizationData>() { new SerializableCivilizationData() { TemplateName = "Template One" }, new SerializableCivilizationData() { TemplateName = "Template Two" } }, CivDiscoveryPairs = new List <Tuple <string, string> >() }; var templateOne = BuildCivTemplate("Template One", Color.white); var templateTwo = BuildCivTemplate("Template Two", Color.red); var composer = Container.Resolve <CivilizationComposer>(); composer.DecomposeCivilizations(mapData); MockCivilizationFactory.Verify( factory => factory.Create(templateOne), Times.Once, "CivFactory did not receive the expected call to create Civ One" ); MockCivilizationFactory.Verify( factory => factory.Create(templateTwo), Times.Once, "CivFactory did not receive the expected call to create Civ Two" ); }
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 DecomposeCivilizations_AssignsStockpilesCorrectly() { var mapData = new SerializableMapData() { Civilizations = new List <SerializableCivilizationData>() { new SerializableCivilizationData() { TemplateName = "Template One", GoldStockpile = 1, CultureStockpile = 10 }, new SerializableCivilizationData() { TemplateName = "Template Two", GoldStockpile = 2, CultureStockpile = 20 } }, CivDiscoveryPairs = new List <Tuple <string, string> >() }; BuildCivTemplate("Template One", Color.white); BuildCivTemplate("Template Two", Color.red); var composer = Container.Resolve <CivilizationComposer>(); composer.DecomposeCivilizations(mapData); var civOne = AllCivilizations.Where(civ => civ.Template.Name.Equals("Template One")).First(); var civTwo = AllCivilizations.Where(civ => civ.Template.Name.Equals("Template Two")).First(); Assert.AreEqual(1, civOne.GoldStockpile, "CivOne.GoldStockpile has an unexpected value"); Assert.AreEqual(10, civOne.CultureStockpile, "CivOne.CultureStockpile has an unexpected value"); Assert.AreEqual(2, civTwo.GoldStockpile, "CivTwo.GoldStockpile has an unexpected value"); Assert.AreEqual(20, civTwo.CultureStockpile, "CivTwo.CultureStockpile has an unexpected value"); }
public void ComposeCells_TerrainRecorded() { var cellOne = BuildHexCell(new HexCoordinates(0, 1)); var cellTwo = BuildHexCell(new HexCoordinates(2, 3)); var cellThree = BuildHexCell(new HexCoordinates(4, 5)); cellOne.Terrain = CellTerrain.Grassland; cellTwo.Terrain = CellTerrain.Desert; cellThree.Terrain = CellTerrain.Snow; var composer = Container.Resolve <HexCellComposer>(); var mapData = new SerializableMapData(); composer.ComposeCells(mapData); var dataLikeCellOne = mapData.HexCells.Where( data => data.Coordinates == cellOne.Coordinates && data.Terrain == cellOne.Terrain ); var dataLikeCellTwo = mapData.HexCells.Where( data => data.Coordinates == cellTwo.Coordinates && data.Terrain == cellTwo.Terrain ); var dataLikeCellThree = mapData.HexCells.Where( data => data.Coordinates == cellThree.Coordinates && data.Terrain == cellThree.Terrain ); Assert.AreEqual(1, dataLikeCellOne.Count(), "Unexpected number of data representing CellOne"); Assert.AreEqual(1, dataLikeCellTwo.Count(), "Unexpected number of data representing CellTwo"); Assert.AreEqual(1, dataLikeCellThree.Count(), "Unexpected number of data representing CellThree"); }
public void DecomposeCivilizations_RebuildsExploredCellsProperly() { var cellOne = BuildCell(new HexCoordinates(1, 1)); var cellTwo = BuildCell(new HexCoordinates(2, 2)); var cellThree = BuildCell(new HexCoordinates(3, 3)); var mapData = new SerializableMapData() { Civilizations = new List <SerializableCivilizationData>() { new SerializableCivilizationData() { TemplateName = "Template One", ExploredCells = new List <HexCoordinates>() { new HexCoordinates(1, 1), new HexCoordinates(3, 3) } } }, ActivePlayer = "Template One", CivDiscoveryPairs = new List <Tuple <string, string> >() }; BuildCivTemplate("Template One", Color.white); var composer = Container.Resolve <CivilizationComposer>(); composer.DecomposeCivilizations(mapData); var civ = AllCivilizations[0]; MockExplorationCanon.Verify(canon => canon.SetCellAsExploredByCiv(cellOne, civ), Times.Once, "CellOne incorrectly left unexplored"); MockExplorationCanon.Verify(canon => canon.SetCellAsExploredByCiv(cellTwo, civ), Times.Never, "CellTwo incorrectly set as explored"); MockExplorationCanon.Verify(canon => canon.SetCellAsExploredByCiv(cellThree, civ), Times.Once, "CellThree incorrectly left unexplored"); }
public void ComposeCells_VegetationRecorded() { var cellOne = BuildHexCell(new HexCoordinates(0, 1)); var cellTwo = BuildHexCell(new HexCoordinates(2, 3)); var cellThree = BuildHexCell(new HexCoordinates(4, 5)); cellOne.Vegetation = CellVegetation.Forest; cellTwo.Vegetation = CellVegetation.Jungle; cellThree.Vegetation = CellVegetation.Forest; var composer = Container.Resolve <HexCellComposer>(); var mapData = new SerializableMapData(); composer.ComposeCells(mapData); var dataLikeCellOne = mapData.HexCells.Where( data => data.Coordinates == cellOne.Coordinates && data.Vegetation == cellOne.Vegetation ); var dataLikeCellTwo = mapData.HexCells.Where( data => data.Coordinates == cellTwo.Coordinates && data.Vegetation == cellTwo.Vegetation ); var dataLikeCellThree = mapData.HexCells.Where( data => data.Coordinates == cellThree.Coordinates && data.Vegetation == cellThree.Vegetation ); Assert.AreEqual(1, dataLikeCellOne.Count(), "Unexpected number of data representing CellOne"); Assert.AreEqual(1, dataLikeCellTwo.Count(), "Unexpected number of data representing CellTwo"); Assert.AreEqual(1, dataLikeCellThree.Count(), "Unexpected number of data representing CellThree"); }
public void DecomposeCivilizations_DoesntStartGoldenAgeIfStoredTurnsLeftIsZero() { var mapData = new SerializableMapData() { Civilizations = new List <SerializableCivilizationData>() { new SerializableCivilizationData() { TemplateName = "Civ One", GoldenAgeProgress = 1, PreviousGoldenAges = 22, GoldenAgeTurnsLeft = 0 } }, ActivePlayer = "Civ One", CivDiscoveryPairs = new List <Tuple <string, string> >() }; BuildCivTemplate("Civ One", Color.white); var composer = Container.Resolve <CivilizationComposer>(); composer.DecomposeCivilizations(mapData); var civ = AllCivilizations[0]; MockGoldenAgeCanon.Verify( canon => canon.StartGoldenAgeForCiv(civ, It.IsAny <int>()), Times.Never ); }
public void DecomposeCells_VegetationChangedThroughCellModificationLogic() { var mapData = new SerializableMapData() { HexCells = new List <SerializableHexCellData>() { new SerializableHexCellData() { Coordinates = new HexCoordinates(0, 0), Vegetation = CellVegetation.Forest }, new SerializableHexCellData() { Coordinates = new HexCoordinates(1, 1), Vegetation = CellVegetation.Marsh }, } }; var composer = Container.Resolve <HexCellComposer>(); composer.DecomposeCells(mapData); var cellOne = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(0, 0))).First(); var cellTwo = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(1, 1))).First(); MockCellModificationLogic.Verify( logic => logic.ChangeVegetationOfCell(cellOne, CellVegetation.Forest), Times.Once, "ChangeVegetationOfCellTo not called properly on cellOne" ); MockCellModificationLogic.Verify( logic => logic.ChangeVegetationOfCell(cellTwo, CellVegetation.Marsh), Times.Once, "ChangeVegetationOfCellTo not called properly on cellTwo" ); }
public void DecomposeDiplomacy_AssemblesWarRelationsCorrectly() { var civOne = BuildCivilization("Civ One"); var civTwo = BuildCivilization("Civ Two"); var civThree = BuildCivilization("Civ Three"); var mapData = new SerializableMapData() { DiplomacyData = new SerializableDiplomacyData() { ActiveWars = new List <Tuple <string, string> >() { new Tuple <string, string>("Civ One", "Civ Two"), new Tuple <string, string>("Civ Two", "Civ Three"), new Tuple <string, string>("Civ Three", "Civ One") } } }; MockWarCanon.Setup(canon => canon.CanDeclareWar(It.IsAny <ICivilization>(), It.IsAny <ICivilization>())) .Returns(true); var composer = Container.Resolve <DiplomacyComposer>(); composer.DecomposeDiplomacy(mapData); MockWarCanon.Verify(canon => canon.CanDeclareWar(civOne, civTwo), Times.Once, "War validity between CivOne and CivTwo not checked"); MockWarCanon.Verify(canon => canon.CanDeclareWar(civTwo, civThree), Times.Once, "War validity between CivTwo and CivThree not checked"); MockWarCanon.Verify(canon => canon.CanDeclareWar(civThree, civOne), Times.Once, "War validity between CivThree and CivOne not checked"); MockWarCanon.Verify(canon => canon.DeclareWar(civOne, civTwo), Times.Once, "War not declared between CivOne and CivTwo"); MockWarCanon.Verify(canon => canon.DeclareWar(civTwo, civThree), Times.Once, "War not declared between CivTwo and CivThree"); MockWarCanon.Verify(canon => canon.DeclareWar(civThree, civOne), Times.Once, "War not declared between CivThree and CivOne"); }
public void DecomposeCells_SuppressSlotSetProperly() { var mapData = new SerializableMapData() { HexCells = new List <SerializableHexCellData>() { new SerializableHexCellData() { Coordinates = new HexCoordinates(0, 0), SuppressSlot = false }, new SerializableHexCellData() { Coordinates = new HexCoordinates(1, 1), SuppressSlot = true }, } }; var composer = Container.Resolve <HexCellComposer>(); composer.DecomposeCells(mapData); var cellOne = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(0, 0))).First(); var cellTwo = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(1, 1))).First(); Assert.AreEqual(false, cellOne.SuppressSlot, "CellOne has an unexpected SuppressSlot value"); Assert.AreEqual(true, cellTwo.SuppressSlot, "CellTwo has an unexpected SuppressSlot value"); }
public void DecomposeDiplomacy_AssemblesProposalsThroughProposalComposer() { var serialProposalOne = new SerializableProposalData(); var serialProposalTwo = new SerializableProposalData(); var serialProposalThree = new SerializableProposalData(); var proposalOne = BuildProposal(); var proposalTwo = BuildProposal(); var proposalThree = BuildProposal(); var mapData = new SerializableMapData() { DiplomacyData = new SerializableDiplomacyData() { ActiveProposals = new List <SerializableProposalData>() { serialProposalOne, serialProposalTwo, serialProposalThree } } }; MockProposalComposer.Setup(composer => composer.DecomposeProposal(serialProposalOne)).Returns(proposalOne); MockProposalComposer.Setup(composer => composer.DecomposeProposal(serialProposalTwo)).Returns(proposalTwo); MockProposalComposer.Setup(composer => composer.DecomposeProposal(serialProposalThree)).Returns(proposalThree); var diplomacyComposer = Container.Resolve <DiplomacyComposer>(); diplomacyComposer.DecomposeDiplomacy(mapData); MockDiplomacyCore.Verify(core => core.SendProposal(proposalOne), Times.Once, "ProposalOne was never sent"); MockDiplomacyCore.Verify(core => core.SendProposal(proposalTwo), Times.Once, "ProposalTwo was never sent"); MockDiplomacyCore.Verify(core => core.SendProposal(proposalThree), Times.Once, "ProposalThree was never sent"); }
public void DecomposeCells_SlotDataSetProperly() { var mapData = new SerializableMapData() { HexCells = new List <SerializableHexCellData>() { new SerializableHexCellData() { Coordinates = new HexCoordinates(0, 0), IsSlotLocked = true, IsSlotOccupied = false }, new SerializableHexCellData() { Coordinates = new HexCoordinates(1, 1), IsSlotLocked = false, IsSlotOccupied = true }, } }; var composer = Container.Resolve <HexCellComposer>(); composer.DecomposeCells(mapData); var cellOne = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(0, 0))).First(); var cellTwo = AllCells.Where(cell => cell.Coordinates.Equals(new HexCoordinates(1, 1))).First(); Assert.AreEqual(true, cellOne.WorkerSlot.IsLocked, "CellOne.WorkerSlot.IsLocked has an unexpected value"); Assert.AreEqual(false, cellOne.WorkerSlot.IsOccupied, "CellOne.WorkerSlot.IsOccupied has an unexpected value"); Assert.AreEqual(false, cellTwo.WorkerSlot.IsLocked, "CellTwo.WorkerSlot.IsLocked has an unexpected value"); Assert.AreEqual(true, cellTwo.WorkerSlot.IsOccupied, "CellTwo.WorkerSlot.IsOccupied has an unexpected value"); }
public void ComposeCities_StoresAppliedFreeBuildingsByName() { var appliedBuildings = new List <IBuildingTemplate>() { BuildBuildingTemplate("Building One"), BuildBuildingTemplate("Building Two"), BuildBuildingTemplate("Building Three"), }; var cityOne = BuildCity( BuildHexCell(new HexCoordinates(0, 0)), BuildCivilization(), "City One", BuildUnit() ); MockFreeBuildingApplier.Setup(applier => applier.GetTemplatesAppliedToCity(cityOne)) .Returns(appliedBuildings); var mapData = new SerializableMapData(); var composer = Container.Resolve <CityComposer>(); composer.ComposeCities(mapData); CollectionAssert.AreEquivalent( appliedBuildings.Select(template => template.name), mapData.Cities[0].AppliedFreeBuildings ); }