public AircraftViewModel(AircraftDto aircraftDto) { this.Id = aircraftDto.Id; this.Name = aircraftDto.Name; this.FuelConsumptionPerMile = aircraftDto.FuelConsumptionPerMile; this.FuelTakeOffEffort = aircraftDto.FuelTakeOffEffort; }
public async Task GetByIdAircraft_WhenAircraftWithId1Valid_ReturnAircraftWithId1() { int id = 1; AircraftDto aircraftDto = await service.GetById <Aircraft, AircraftDto>(x => x.Id == id); Assert.AreEqual(id, aircraftDto.Id); }
public async Task Delete_WhenNull_ReturnNoContent() { AircraftDto aircraft = new AircraftDto(); A.CallTo(() => service.Delete(aircraft.Id)).Returns(true); IActionResult result = await aircraftsController.Delete(aircraft.Id); Assert.True(result is NoContentResult); }
public async Task CreateAircraft_WhenTypeAircraftIdInvalid_ThenReturnExeption() { AircraftDto aircraft = new AircraftDto() { AircraftName = "TEST", TypeAircraftId = 1000 }; AircraftDto aircraftDtoSaved = await service.Create(aircraft); }
public async Task <IActionResult> Get(int id) { AircraftDto Aircraft = await service.GetById(id); if (Aircraft == null) { return(NotFound()); } return(Ok(Aircraft)); }
public async Task CreateAircraft_WhenIdSend_ThenReturnExeption() { AircraftDto aircraft = new AircraftDto() { Id = 5, AircraftName = "TEST", TypeAircraftId = 1 }; AircraftDto aircraftDtoSaved = await service.Create(aircraft); }
public IActionResult Get(int id) { AircraftDto Aircraft = service.GetById(id); if (Aircraft == null) { return(NotFound()); } return(Ok(Aircraft)); }
public async Task Update_WhenAircraftNull_ThenReturnExeption() { var aircrafts = new IFakeRepository <Aircraft>(); var context = new IFakeUnitOfFactory(); AircraftDto aircraftDto = null; AircraftService service = new AircraftService(context); AircraftDto aircraftDtoSaved = await service.Update(aircraftDto); }
public async Task Post_WhenInvalidAircraft_ReturnCreatedResult() { AircraftDto aircraft = new AircraftDto() { AircraftName = "Test", TypeAircraftId = 10 }; A.CallTo(() => service.Create(aircraft)).Returns(aircraft); IActionResult result = await aircraftsController.Post(aircraft); Assert.True(result is CreatedResult); }
public async Task UpdateAircraft_WhenAircraftIdInvalid_ReturnNull() { AircraftDto aircraft = new AircraftDto() { Id = 999, AircraftName = "TEST", TypeAircraftId = 1 }; AircraftDto aircraftDtoUpdated = await service.Update <AircraftDto, Aircraft>(aircraft); Assert.IsNull(aircraftDtoUpdated); }
public async Task CreateAircraft_WhenAircraftValid_ReturnNewAircraft() { AircraftDto aircraft = new AircraftDto() { AircraftName = "TEST", TypeAircraftId = 1 }; AircraftDto aircraftDtoSaved = await service.Create(aircraft); Assert.AreEqual(aircraft.AircraftName, aircraftDtoSaved.AircraftName); Assert.AreEqual(aircraft.TypeAircraftId, aircraftDtoSaved.TypeAircraftId); bool result = await service.Delete <Aircraft>(aircr => aircr.Id == aircraftDtoSaved.Id); Assert.IsTrue(result); }
private static List <Triple> ConvertAircraft(AircraftDto aircraft) { return(new TripleBuilder(nodeFactory.AsBlankNode(aircraft.NodeId)) .Add(nodeFactory.AsUriNode(Constants.Predicates.Type), nodeFactory.AsValueNode(Constants.Types.Aircraft)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftEngineHorsepower), nodeFactory.AsValueNode(aircraft.EngineHorsepower)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftEngineManufacturer), nodeFactory.AsValueNode(aircraft.EngineManufacturer)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftEngineModel), nodeFactory.AsValueNode(aircraft.EngineModel)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftEngineThrust), nodeFactory.AsValueNode(aircraft.EngineThrust)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftManufacturer), nodeFactory.AsValueNode(aircraft.AircraftManufacturer)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftModel), nodeFactory.AsValueNode(aircraft.AircraftModel)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftN_Number), nodeFactory.AsValueNode(aircraft.N_Number)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftSeats), nodeFactory.AsValueNode(aircraft.AircraftSeats)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftSerialNumber), nodeFactory.AsValueNode(aircraft.SerialNumber)) .Add(nodeFactory.AsUriNode(Constants.Predicates.AircraftUniqueId), nodeFactory.AsValueNode(aircraft.UniqueId)) .Build()); }
public IActionResult Put(int id, [FromBody] AircraftDto Aircraft) { if (Aircraft == null) { ModelState.AddModelError("", "Не указаны данные для cамолёта"); return(BadRequest(ModelState)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } service.Update(Aircraft); return(Ok(Aircraft)); }
public IActionResult Post([FromBody] AircraftDto Aircraft) { if (Aircraft == null) { ModelState.AddModelError("", "Не указаны данные для cамолёта"); return(BadRequest(ModelState)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } service.Create(Aircraft); return(Created("api/Aircrafts", Aircraft)); }
public async Task Update_WhenValidAircraft_ThenReturnAircraft() { var aircrafts = new IFakeRepository <Aircraft>(); var context = new IFakeUnitOfFactory(); AircraftDto aircraftDto = new AircraftDto() { Id = 154, AircraftName = "Test", TypeAircraftId = 165 }; AircraftService service = new AircraftService(context); AircraftDto aircraftDtoSaved = await service.Update(aircraftDto); Assert.AreEqual(aircraftDto.AircraftName, aircraftDtoSaved.AircraftName); Assert.AreEqual(aircraftDto.Id, aircraftDtoSaved.Id); Assert.AreEqual(aircraftDto.TypeAircraftId, aircraftDtoSaved.TypeAircraftId); }
public async Task UpdateAircraft_WhenAircraftWithId_ReturnUpdatedAircraftWithId() { AircraftDto aircraft = new AircraftDto() { AircraftName = "TEST", TypeAircraftId = 1 }; AircraftDto aircraftDtoSaved = await service.Create(aircraft); aircraftDtoSaved.AircraftName = "TEST2"; aircraftDtoSaved.TypeAircraftId = 2; AircraftDto aircraftDtoUpdated = await service.Update <AircraftDto, Aircraft>(aircraftDtoSaved); Assert.AreEqual(aircraftDtoSaved.AircraftName, aircraftDtoUpdated.AircraftName); Assert.AreEqual(aircraftDtoSaved.TypeAircraftId, aircraftDtoUpdated.TypeAircraftId); bool result = await service.Delete <Aircraft>(aircr => aircr.Id == aircraftDtoUpdated.Id); Assert.IsTrue(result); }
public async Task <AircraftDto> Update(AircraftDto entity) { return(await Update <AircraftDto, Aircraft>(entity)); }
public async Task GetByIdAircraft_WhenAircraftIdInvalid_ReturnNull() { AircraftDto aircraftDto = await service.GetById <Aircraft, AircraftDto>(x => x.Id == 999); Assert.IsNull(aircraftDto); }
private double FuelConsumption(AircraftDto aircraft, double distance) { return(aircraft.FuelConsumption * distance + aircraft.TakeOffEffort); }
public void Create(AircraftDto entity) { Create <AircraftDto, Aircraft>(entity); }
public void Update(AircraftDto entity) { Update <AircraftDto, Aircraft>(entity); }