Пример #1
0
        public async Task <ActionResult <List <UnitCommitmentModel> > > Post([FromBody] PlanCommand planCommand)
        {
            var result = await _mediator.Send(planCommand);

            await _hubContext.Clients.All.SendAsync("UnitCommitmentUpdate", planCommand, result);

            return(Ok(result));
        }
Пример #2
0
        public async Task ShouldReturnsListWithPowersEqualToProvidedLoadSample3()
        {
            // Arrange
            var command = new PlanCommand()
            {
                Load  = 910,
                Fuels = new Fuel
                {
                    Gas      = 13.4M,
                    Kerosine = 50.8M,
                    Co2      = 20,
                    Wind     = 60
                },
                PowerPlants = new List <PowerPlant>
                {
                    new PowerPlant
                    {
                        Name       = "gasfiredbig1",
                        Type       = PowerPlantType.GasFired,
                        Efficiency = 0.53M,
                        PMin       = 100,
                        PMax       = 460
                    },
                    new PowerPlant
                    {
                        Name       = "gasfiredbig2",
                        Type       = PowerPlantType.GasFired,
                        Efficiency = 0.53M,
                        PMin       = 100,
                        PMax       = 460
                    },
                    new PowerPlant
                    {
                        Name       = "gasfiredsomewhatsmaller",
                        Type       = PowerPlantType.GasFired,
                        Efficiency = 0.37M,
                        PMin       = 40,
                        PMax       = 210
                    },
                    new PowerPlant
                    {
                        Name       = "tj1",
                        Type       = PowerPlantType.Turbojet,
                        Efficiency = 0.3M,
                        PMin       = 0,
                        PMax       = 16
                    },
                    new PowerPlant
                    {
                        Name       = "windpark1",
                        Type       = PowerPlantType.WindTurbine,
                        Efficiency = 1,
                        PMin       = 0,
                        PMax       = 150
                    },
                    new PowerPlant
                    {
                        Name       = "windpark2",
                        Type       = PowerPlantType.WindTurbine,
                        Efficiency = 1,
                        PMin       = 0,
                        PMax       = 36
                    }
                }
            };
            // Act
            var result = await SendAsync(command);

            // Assert
            var resultingLoad = result.Sum(x => x.Power);

            resultingLoad.Should().Be(command.Load);
        }