예제 #1
0
        public void GetByCallSid_CallId()
        {
            // 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
            string receiverSid = string.Empty;
            repositoryMock.Setup(r => r.Query<Call>())
                .Returns(new List<Call>().AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object,
                settingMock.Object, componentMock.Object);
            callService.GetByCallSid(string.Empty);

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