public void Get_RepositoryException() { mockPersonRepository = new Mock <IRepository <Person> >(); mockPersonRepository.Setup(x => x.Get(It.IsAny <int>())).Throws(new Exception("Repository not found")); contract = new PassengersContract(mockPersonRepository.Object, mockBookingRepository.Object); int id = 91; var result = contract.Get(id); }
public void GetAll_RepositoryInvalidResponse() { mockBookingRepository = new Mock <IRepository <Booking> >(); mockBookingRepository.Setup(x => x.GetAll()).Returns((List <Booking>)null); contract = new PassengersContract(mockPersonRepository.Object, mockBookingRepository.Object); string flightNumber = "PZ696"; var result = contract.GetByFlight(flightNumber); }
public void Init() { mockPersonRepository = new Mock <IRepository <Person> >(); mockBookingRepository = new Mock <IRepository <Booking> >(); mockPersonRepository.Setup(x => x.Get(It.IsAny <int>())).Returns((int x) => new MockPersonRepository().Get(x)); mockPersonRepository.Setup(x => x.GetAll()).Returns(() => new MockPersonRepository().GetAll()); mockBookingRepository.Setup(x => x.Get(It.IsAny <int>())).Returns((int x) => new MockBookingRepository().Get(x)); mockBookingRepository.Setup(x => x.GetAll()).Returns(() => new MockBookingRepository().GetAll()); contract = new PassengersContract(mockPersonRepository.Object, mockBookingRepository.Object); }