public void Create_When_gets_Valid_Then_Insert() { PilotDTO pilotDTO = new PilotDTO() { Name = "Quest", Surname = "Quest" }; //Arrange var service = new PilotService(_unit); //Act&Assert Assert.DoesNotThrow(() => service.CreatePilot(pilotDTO)); }
public void Create_When_gets_notValidId_Then_return_exception() { //Arrange PilotDTO pilotDTO = new PilotDTO() { Id = 1, Name = "The ", Surname = "Most" }; var service = new PilotService(_unit); //Act & Assert Assert.Throws <ArgumentOutOfRangeException>(() => service.CreatePilot(pilotDTO)); }
public void Create_When_gets_notValid_Then_return_exception() { //Arrange PilotDTO pilotDTO = new PilotDTO() { Id = 7, Name = "The most amazing thing on the earth is a coffee without any milk and sugar.he most amazing thing on the earth is a coffee without any milk and sugar.he most amazing thing on the earth is a coffee without any milk and sugar. The most amazing thing on the earth is a coffee without any milk and sugar.he most amazing thing on the earth is a coffee without any milk and sugar.he most amazing thing on the earth is a coffee without any milk and sugar. ", Surname = "Quest" }; var service = new PilotService(_unit); //Act & Assert Assert.Throws <AutoMapperMappingException>(() => service.CreatePilot(pilotDTO)); }
public void PilotCreate() { PilotService pilotService = new PilotService(unitOfWork); PilotDTO pilotDTO = new PilotDTO() { Name = "pilotCreateTest", Surname = "pilotCreateTest", Birth = new DateTime(1990, 1, 1), Experience = new TimeSpan(1, 2, 3) }; pilotService.CreatePilot(pilotDTO); Pilot pilot = fakePilotRepo.Get(1); Assert.AreEqual(pilot.Name, pilotDTO.Name); Assert.AreEqual(pilot.Surname, pilotDTO.Surname); Assert.AreEqual(pilot.Birth, pilotDTO.Birth); Assert.AreEqual(pilot.Experience, pilotDTO.Experience); }
public void Create_When_gets_null_Then_return_exception() { ////Arrange //var fakePilotRepo = A.Fake<Repository<Pilot>>(); //A.CallTo(() => fakePilotRepo.GetEntities(null, null, string.Empty)).Returns(new List<Pilot> { new Pilot { Id = 45 }, new Pilot { Id = 46 }, new Pilot { Id = 47 } }); //var fakeUnitOfWork = A.Fake<IUnitOfWork>(); //A.CallTo(() => fakeUnitOfWork.PilotsRepo).Returns(fakePilotRepo); //var service = new PilotService(fakeUnitOfWork as UnitOfWork); ////Act & Assert //Assert.Throws<ArgumentNullException>(() => service.CreatePilot(null)); var service = new PilotService(_unit); Assert.Throws <ArgumentNullException>(() => service.CreatePilot(null)); }