public void UpdateEntity_Should_Update_pilot_typeof_Pilot()
        {
            // Arrange
            PilotDTO pilotDTO = new PilotDTO
            {
                Id         = 1,
                FirstName  = "Bob",
                LastName   = "Henk",
                Experience = 10,
                BirthDate  = new DateTime(1998, 07, 12)
            };
            Pilot pilot = new Pilot
            {
                Id         = 1,
                FirstName  = "Bob",
                LastName   = "Henk",
                Experience = 10,
                BirthDate  = new DateTime(1998, 07, 12)
            };

            var pilotRepository = A.Fake <IRepository <Pilot> >();

            A.CallTo(() => pilotRepository.Get(A <int> ._)).Returns(new Pilot {
                Id = 1
            });

            var pilotService = new PilotService(pilotRepository);

            //Act
            pilotService.UpdateEntity(1, pilotDTO);
            var result = pilotRepository.Get(1);

            // Assert
            Assert.AreEqual(pilot, result);
        }
Esempio n. 2
0
 public async void UpdatePilot()
 {
     if (await service.UpdateEntity(SelectedPilot.Id, SelectedPilot))
     {
         var tempPilot = Pilots.FirstOrDefault(c => c.Id == SelectedPilot.Id);
         tempPilot.FirstName  = SelectedPilot.FirstName;
         tempPilot.LastName   = SelectedPilot.LastName;
         tempPilot.Birthday   = SelectedPilot.Birthday;
         tempPilot.Experience = SelectedPilot.Experience;
     }
 }
        public void UpdateEntity_When_pilot_doesnt_exist_Then_throw_exception()
        {
            // Arrange
            PilotDTO pilotDTO = new PilotDTO
            {
                Id         = 1,
                FirstName  = "Bob",
                LastName   = "Henk",
                Experience = 10,
                BirthDate  = new DateTime(1998, 07, 12)
            };

            var pilotRepository = A.Fake <IRepository <Pilot> >();

            A.CallTo(() => pilotRepository.Get(A <int> ._)).Returns(null);
            var pilotService = new PilotService(pilotRepository);

            //Act and Assert
            Assert.Throws <ValidationException>(() => pilotService.UpdateEntity(1, pilotDTO));
        }