Exemple #1
0
        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 void Update_Should_UpdateAircraftInDatabase_When_Called()
        {
            var plane   = _aircraftService.GetAll().First();
            var oldName = plane.AircraftName;

            plane.AircraftName = "New Name";

            _aircraftService.Update(plane);
            Assert.AreNotEqual(plane.AircraftName, oldName);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public async Task Update()
        {
            Aircraft AircraftUpdated = await AircraftService.Update(Aircraft, Aircraft.Id);

            Aircraft = new Aircraft();

            List <Aircraft> tempAircrafts = await AircraftService.GetAll();

            Aircrafts = new ObservableCollection <Aircraft>();
            foreach (var fl in tempAircrafts)
            {
                Aircrafts.Add(fl);
            }
            NotifyPropertyChanged(() => Aircrafts);
        }
Exemple #5
0
        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 IActionResult Save(SaveAircraftModel model)
        {
            if (model.AircraftId.HasValue)
            {
                _aircraftService.Update(model.AircraftId.Value, model.TailNumber, model.TypeId, model.ModelId, model.HomebaseId, model.ArgusSafetyRating,
                                        model.WyvernSafetyRating, model.ManufactureYear, model.LastIntRefurbish, model.LastExtRefurbish, model.MaxPassengers,
                                        model.HoursFlown, model.Speed, model.Range, model.WiFi, model.BookableDemo, model.NumberOfTelevision,
                                        model.CargoCapability, model.SellAsCharterAircraft, model.SellAsCharterSeat, model.PricePerHour, model.Images,
                                        model.Documents);
            }
            else
            {
                _aircraftService.Create(model.TailNumber, model.TypeId, model.ModelId, model.HomebaseId, model.ArgusSafetyRating,
                                        model.WyvernSafetyRating, model.ManufactureYear, model.LastIntRefurbish, model.LastExtRefurbish, model.MaxPassengers,
                                        model.HoursFlown, model.Speed, model.Range, model.WiFi, model.BookableDemo, model.NumberOfTelevision,
                                        model.CargoCapability, model.SellAsCharterAircraft, model.SellAsCharterSeat, model.PricePerHour, model.Images,
                                        model.Documents);
            }

            return(Ok());
        }
Exemple #7
0
 public void Update_Should_CallRepositoryUpdate_When_Called()
 {
     _aircraftService.Update(_plane1DTO);
     A.CallTo(() => _fakeUnitOfWork.AircraftRepository.Update(A <Aircraft> .That.IsInstanceOf(typeof(Aircraft)), null)).MustHaveHappenedOnceExactly();
 }