Ejemplo n.º 1
0
        public void CreatePilot_WhenInvalid_ThrowsArgumentNullException(string fName, string lName)
        {
            var pilot = new PilotDTO
            {
                FirstName   = fName,
                LastName    = lName,
                DateOfBirth = new DateTime(1990, 12, 2),
                Experience  = 2
            };

            var service = new PilotService(fakeUnitOfWork, mapper);

            Assert.ThrowsAsync <ArgumentNullException>(
                () => service.Add(pilot));
        }
Ejemplo n.º 2
0
        public async Task CreatePilot_WhenValid_ShouldCreatePilotInDb()
        {
            var pilot = new PilotDTO
            {
                FirstName   = "test_pilot",
                LastName    = "test_pilot2",
                DateOfBirth = new DateTime(1990, 12, 2),
                Experience  = 2
            };

            var service = new PilotService(fakeUnitOfWork, mapper);

            await service.Add(pilot);

            var result = fakeUnitOfWork.PilotRepository.GetAll().Result.FirstOrDefault(
                x => x.FirstName == "test_pilot" && x.LastName == "test_pilot2" && x.Experience == 2);

            Assert.IsNotNull(result);
        }
 public void Add_Should_CallRepositoryCreate_When_Called()
 {
     _pilotService.Add(_pilotDTO);
     A.CallTo(() => _fakeUnitOfWork.Set <Pilot>().Create(A <Pilot> .That.IsInstanceOf(typeof(Pilot)), null)).MustHaveHappenedOnceExactly();
 }