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));
        }
Beispiel #3
0
        private void UpdateTargetList()
        {
            var targetOrbitBodyInfo = _terraformGameState.GetTargetsFor(_systemBodyId, _populationId);

            this.listView_TerraformTargets.Items.Clear();
            this.listView_TerraformTargets.Items.AddRange(UiModelMapper.GenerateTargetsList(targetOrbitBodyInfo).ToArray());

            this.listView_TerraformTargets.Refresh();
        }
        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));
        }