public async Task Create(CrewDTO crewDto) { Pilot pilot; Stewardess stewardess; try { pilot = await _pilotService.Get(crewDto.PilotId); stewardess = await _stewardessService.Get(crewDto.StewardessId); } catch (System.Exception) { return; } pilot.Id = 0; stewardess.Id = 0; Crew crew = new Crew { Pilot = pilot, Stewardesses = new List <Stewardess> { stewardess } }; await _service.Create(crew); await UpdateList(); }
public void Pilots_When_get_from_get_all_by_id_and_get_by_id_Then_results_are_equals() { var pilotService = new PilotService(unitOfWork, mapper, new PilotValidator()); var id = 2; var pilots = pilotService.Get(); var pilot = pilotService.Get(id); var resultFromList = pilots.SingleOrDefault(x => x.ID == id); Assert.AreEqual(pilot.Birthday, resultFromList.Birthday); Assert.AreEqual(pilot.FirstName, resultFromList.FirstName); Assert.AreEqual(pilot.LastName, resultFromList.LastName); Assert.AreEqual(pilot.Experience, resultFromList.Experience); }
public void Get_by_id_When_is_not_exists_Then_throws_NullReferenceException() { var pilotService = new PilotService(unitOfWork, mapper, new PilotValidator()); var id = 1123; Assert.Throws <NullReferenceException>(() => pilotService.Get(id)); }
public void Create_When_PilotModel_is_valid_Then_return_id() { var expectedPilot = new PilotDto() { Birthday = DateTime.Now.AddYears(-30), FirstName = "Alex", LastName = "Zamekula", Experience = 3 }; int id = service.Create(expectedPilot); var actualPilot = service.Get(id); Assert.AreEqual(expectedPilot.FirstName, actualPilot.FirstName); Assert.AreEqual(expectedPilot.LastName, actualPilot.LastName); Assert.AreEqual(expectedPilot.Birthday, actualPilot.Birthday); }
public void Create_Pilot_When_get_Then_find() { var pilotService = new PilotService(unitOfWork, mapper, new PilotValidator()); var id = pilotService.Create(new BSA2018_Hometask4.Shared.DTO.PilotDto { Birthday = DateTime.Now.AddYears(-30), Experience = 3, FirstName = "Oleksii", LastName = "Bogdanovych" }); Assert.AreEqual(id, pilotService.Get(id).ID); pilotService.Delete(id); }