Ejemplo n.º 1
0
        public void GetByIdShould_CallRepositoryMethodGetById()
        {
            var repositoryMock = new Mock <IRepository <Booking> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IBookingFactory>();

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

            service.GetById(id);

            repositoryMock.Verify(r => r.GetById(id));
        }
Ejemplo n.º 2
0
        public void GetByIdShould_ReturnCorrectValue()
        {
            var repositoryMock = new Mock <IRepository <Booking> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IBookingFactory>();

            var id      = Guid.NewGuid();
            var booking = new Booking()
            {
                Id = id
            };

            repositoryMock.Setup(r => r.GetById(id)).Returns(booking);

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

            var result = service.GetById(id);

            Assert.AreSame(booking, result);
        }