Ejemplo n.º 1
0
        public void GetByBookingId_AnyIds()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var uowMock = new Mock<IUnitOfWork>();
            var repositoryMock = new Mock<IRepository>();
            var serviceLocatorMock = new Mock<IServiceLocator>();

            serviceLocatorMock.Setup(r => r.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange data
            Guid id = Guid.NewGuid();
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                Booking = new Booking
                {
                    Id = id
                }
            };
            Call[] calls = new Call[] { call };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            callService.GetByBookingId(id);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());
        }