예제 #1
0
        public void CreateBookingShould_CallRepositoryMethodAdd(string userId, int people)
        {
            var repositoryMock = new Mock <IRepository <Booking> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IBookingFactory>();

            var service = new Services.BookingService(repositoryMock.Object,
                                                      unitOfWorkMock.Object, factoryMock.Object);

            var placeId  = Guid.NewGuid();
            var dateTime = DateTime.Now;
            var booking  = new Booking()
            {
                PlaceId        = placeId,
                UserId         = userId,
                DateTime       = dateTime,
                NumberOfPeople = people
            };

            factoryMock.Setup(f => f.CreateBooking(placeId, userId, dateTime, people))
            .Returns(booking);

            service.CreateBooking(placeId, userId, dateTime, people);

            repositoryMock.Verify(r => r.Add(booking), Times.Once);
        }
예제 #2
0
        public void CreateBookingShould_CallFactoryMethodCreateBooking(string userId, int people)
        {
            var repositoryMock = new Mock <IRepository <Booking> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IBookingFactory>();

            var service = new Services.BookingService(repositoryMock.Object,
                                                      unitOfWorkMock.Object, factoryMock.Object);

            var placeId  = Guid.NewGuid();
            var dateTime = DateTime.Now;

            service.CreateBooking(placeId, userId, dateTime, people);

            factoryMock.Verify(f => f.CreateBooking(placeId, userId, dateTime, people));
        }