Beispiel #1
0
        public void MethodCreateShould_CallFactoryMethodCreateBooking(int peopleCount)
        {
            var service = new BookingsService(repositoryMock.Object,
                                              unitOfWorkMock.Object, factoryMock.Object, restaurantsServiceMock.Object);

            var restaurantId = Guid.NewGuid();
            var userId       = Guid.NewGuid();
            var dateTime     = DateTime.Now;

            service.Create(restaurantId, userId, dateTime, peopleCount);

            factoryMock.Verify(f => f.Create(restaurantId, userId, dateTime, peopleCount));
        }
Beispiel #2
0
        public void MethodCreateShould_CallRepositoryMethodAdd(int peopleCount)
        {
            var service = new BookingsService(repositoryMock.Object,
                                              unitOfWorkMock.Object, factoryMock.Object, restaurantsServiceMock.Object);

            var restaurantId = Guid.NewGuid();
            var userId       = Guid.NewGuid();

            var dateTime = DateTime.Now;
            var booking  = new Booking()
            {
                RestaurantId = restaurantId,
                UserId       = userId,
                DateTime     = dateTime,
                PeopleCount  = peopleCount
            };

            factoryMock.Setup(f => f.Create(restaurantId, userId, dateTime, peopleCount))
            .Returns(booking);

            service.Create(restaurantId, userId, dateTime, peopleCount);

            repositoryMock.Verify(r => r.Add(booking), Times.Once);
        }