コード例 #1
0
        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>();
        }
コード例 #2
0
        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);
        }