public void CreateAccomodationShouldThrowExceptionWhenAccomodationAlreadyExist() { //Init var accomodation = AccomodationTest.GetAccomodation(); var accomodationQuery = Substitute.For <AccomodationQuery>(); var accomodationRepository = Substitute.For <AccomodationRepository>(); var service = new AccomodationServiceImpl(accomodationRepository, accomodationQuery); accomodationQuery.Exist(accomodation).Returns(true); //Action //Assert Check.ThatCode(() => { service.CreateAccomodation(accomodation); }) .Throws <AccomodationAlreadyExistException>(); }
public void CreateAccomodationShouldCallRepository() { //Init var accomodation = AccomodationTest.GetAccomodation(); var accomodationQuery = Substitute.For <AccomodationQuery>(); var accomodationRepository = Substitute.For <AccomodationRepository>(); var service = new AccomodationServiceImpl(accomodationRepository, accomodationQuery); accomodationQuery.Exist(accomodation).Returns(false); //Action service.CreateAccomodation(accomodation); //Assert accomodationRepository.Received().Create(accomodation); }