public void GameState_IfAllTargetsAreDeleted_Should_RemoveEntryEntirely()
        {
            var mockState           = TerraformMockHelpers.Setup_MockGameStateData_Targets();
            var mockStateCurrent    = TerraformMockHelpers.Setup_MockGameStateData_Elements();
            var mockProcessedResult = new ProcessedTerraformingListResult()
            {
                newTargets = mockState,
                newValues  = mockStateCurrent
            };

            var gameDataHandlerMock = TerraformMockHelpers.SetupMock_IOrbitBodyTerraformDataHandler(mockState);
            var managerMock         = TerraformMockHelpers.SetupMock_ITerraformingManager(mockProcessedResult);
            var gameState           = new TerraformGameState(gameDataHandlerMock.Object, managerMock.Object);

            gameState.SetTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 1, targetAmount: 1.1);

            var fetchTarget = gameState.GetTargetsFor(orbitBodyId: 9999, populationId: 8888);

            Assert.AreEqual(1.1, fetchTarget.DesiredTargets.GetAmount(1));

            gameState.DeleteTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 1);
            fetchTarget = gameState.GetTargetsFor(orbitBodyId: 9999, populationId: 8888);

            Assert.IsNull(fetchTarget);
        }
        public void GameState_DeletingATarget_Should_RemoveCorrectly()
        {
            var mockState           = TerraformMockHelpers.Setup_MockGameStateData_Targets();
            var mockStateCurrent    = TerraformMockHelpers.Setup_MockGameStateData_Elements();
            var mockProcessedResult = new ProcessedTerraformingListResult()
            {
                newTargets = mockState,
                newValues  = mockStateCurrent
            };

            var gameDataHandlerMock = TerraformMockHelpers.SetupMock_IOrbitBodyTerraformDataHandler(mockState);
            var managerMock         = TerraformMockHelpers.SetupMock_ITerraformingManager(mockProcessedResult);
            var gameState           = new TerraformGameState(gameDataHandlerMock.Object, managerMock.Object);

            gameState.SetTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 1, targetAmount: 1.1);
            gameState.SetTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 2, targetAmount: 2.2);
            gameState.SetTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 3, targetAmount: 3.3);

            gameState.DeleteTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 2);

            var fetchTarget = gameState.GetTargetsFor(orbitBodyId: 9999, populationId: 8888);

            Assert.AreEqual(1.1, fetchTarget.DesiredTargets.GetAmount(1));
            Assert.IsFalse(fetchTarget.DesiredTargets.IsPresent(2));
            Assert.AreEqual(3.3, fetchTarget.DesiredTargets.GetAmount(3));
        }
        public void Initialize()
        {
            _mockCapGetter = TerraformMockHelpers.SetupMock_IPopulationTerraformCapacity(0.3);

            _terraformManager = new TerraformingManager(_mockCapGetter.Object);
            _dice             = new DiceRoller();
        }
        public void GameState_SettingANewTarget_Should_AddCorrectly()
        {
            var mockState           = TerraformMockHelpers.Setup_MockGameStateData_Targets();
            var mockStateCurrent    = TerraformMockHelpers.Setup_MockGameStateData_Elements();
            var mockProcessedResult = new ProcessedTerraformingListResult()
            {
                newTargets = mockState,
                newValues  = mockStateCurrent
            };

            var gameDataHandlerMock = TerraformMockHelpers.SetupMock_IOrbitBodyTerraformDataHandler(mockState);
            var managerMock         = TerraformMockHelpers.SetupMock_ITerraformingManager(mockProcessedResult);
            var gameState           = new TerraformGameState(gameDataHandlerMock.Object, managerMock.Object);

            gameState.SetTargetFor(orbitBodyId: 9999, populationId: 8888, elementId: 777, targetAmount: 100.0);

            var fetchTarget = gameState.GetTargetsFor(orbitBodyId: 9999, populationId: 8888);

            Assert.AreEqual(100.0, fetchTarget.DesiredTargets.GetAmount(777));
        }
        public void Manager_TerraformGameState_OneInvoke_Should_ProcessOnceOnly()
        {
            var mockState           = TerraformMockHelpers.Setup_MockGameStateData_Targets();
            var mockStateCurrent    = TerraformMockHelpers.Setup_MockGameStateData_Elements();
            var mockProcessedResult = new ProcessedTerraformingListResult()
            {
                newTargets = mockState,
                newValues  = mockStateCurrent
            };

            var gameDataHandlerMock = TerraformMockHelpers.SetupMock_IOrbitBodyTerraformDataHandler(mockState);
            var managerMock         = TerraformMockHelpers.SetupMock_ITerraformingManager(mockProcessedResult);
            var gameState           = new TerraformGameState(gameDataHandlerMock.Object, managerMock.Object);

            gameState.DoGameUpdate();

            gameDataHandlerMock.Verify(m => m.GetAllPopulationsTerraformInfo(), Times.Once);
            managerMock.Verify(m => m.ProcessAll(It.IsAny <List <OrbitBodyWithTerraformInfo> >(), It.IsAny <List <OrbitBodyWithCurrentElementInfo> >(), 3600 * 24 * 5), Times.Once);
            gameDataHandlerMock.Verify(m => m.SetAllPopulationsTerraformInfo(mockState), Times.Once);
        }