public override PayLoad ToModel(PayLoadDto dto)
        {
            var payLoad = new PayLoad();

            payLoad.Load = dto.Load;

            if (dto.PowerPlants == null || !dto.PowerPlants.Any())
            {
                throw new Exception("mandatory field {powerplants} missing and shoud be an array of {powerplant object}");
            }

            var powerPlants = _powerPlantConverter.ToModels(dto.PowerPlants);

            var fuels = _fuelConverter.ToModel(new FuelDto {
                Fuels = dto.Fuels
            });



            foreach (var p in powerPlants)
            {
                p.Fuel = p switch
                {
                    WindTurbinePowerPlant w => fuels.First(f => f.GetType() == typeof(WindFuel)),
                    GasFiredPowerPlant g => fuels.First(f => f.GetType() == typeof(GasFuel)),
                    _ => fuels.First(f => f.GetType() == typeof(KerosineFuel)),
                };
            }

            payLoad.Fuels       = fuels;
            payLoad.PowerPlants = (IList <GenericPowerPlant>)powerPlants;

            return(payLoad);
        }
        public void CanConvertPowerPlantToDto()
        {
            // setup
            var powerplantConverter     = new PowerPlantConverter();
            WindTurbinePowerPlant model = new WindTurbinePowerPlant {
                Name = "wind1", Efficiency = 0.58f, Pmin = 0, Pmax = 150, WindPercentage = 0.60f
            };
            var dto = powerplantConverter.ToDto(model);

            //act

            Assert.AreEqual(dto.Name, model.Name);
            Assert.AreEqual(dto.Power, model.Power);
        }