当前位置: 首页>>代码示例>>C#>>正文


C# Call.AsQueryable方法代码示例

本文整理汇总了C#中Call.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# Call.AsQueryable方法的具体用法?C# Call.AsQueryable怎么用?C# Call.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Call的用法示例。


在下文中一共展示了Call.AsQueryable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateCallStatus_CallNull_ReceiverSid

        public void UpdateCallStatus_CallNull_ReceiverSid()
        {
            // 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 = "12345";
            string status = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                ReceiverSid = string.Empty
            };
            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);
            CallDto currentCall = callService.UpdateCallStatus(receiverSid, status);

            // Assert
            Assert.AreEqual(currentCall, null);
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:30,代码来源:CallServiceTest.cs

示例2: UpdateCallStatus_CallNotNull_CallSid

        public void UpdateCallStatus_CallNotNull_CallSid()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();

            serviceLocatorMock.Setup(r => r.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            serviceLocatorMock.Setup(r => r.GetInstance<IUnitOfWork>())
                .Returns(uowMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);
            repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object);
            // Arrange data
            string callSid = "12345";
            string callerStatus = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                CallerSid = callSid
            };
            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);
            CallDto currentCall = callService.UpdateCallStatus(callSid, callerStatus);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(currentCall.CallerStatus, callerStatus);
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:35,代码来源:CallServiceTest.cs

示例3: GetByBookingId_AnyIds

        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>());
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:33,代码来源:CallServiceTest.cs

示例4: GetCallInProgressByCallerId_AnyIds_CallerStatusQueued

        public void GetCallInProgressByCallerId_AnyIds_CallerStatusQueued()
        {
            // 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();
            string callerStatus = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                CallerStatus = callerStatus,
                Caller = new User { 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);
            var currentCall = callService.GetCallByCallerIdAndStatus(id, callerStatus);

            // Assert
            Assert.AreEqual(call.Caller.Id, currentCall.Caller.Id);
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:32,代码来源:CallServiceTest.cs

示例5: RatingCalculator_GuidId

        public void RatingCalculator_GuidId()
        {
            var settingsMock = new Mock<ISettings>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(r => r.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);

            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange data
            Guid id = Guid.NewGuid();
            User user = new User { Id = id };

            Booking booking = new Booking
            {
                Id = Guid.NewGuid(),
                Specialist = user
            };

            Call call1 = new Call
            {
                Id = Guid.NewGuid(),
                Booking = booking,
                Rating = 2
            };
            Call call2 = new Call
            {
                Id = Guid.NewGuid(),
                Booking = booking,
                Rating = 4
            };

            User[] users = new User[] { user };
            repositoryMock.Setup(r => r.Query<User>()).Returns(users.AsQueryable());

            Booking[] bookings = new Booking[] { booking };
            repositoryMock.Setup(r => r.Query<Booking>()).Returns(bookings.AsQueryable());

            Call[] calls = new Call[] { call1, call2 };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            double expectedValue = 3;

            // Act
            var bookingService = new BookingService(uowMock.Object, repositoryMock.Object, settingsMock.Object);
            double currentValue = bookingService.RatingCalculator(id);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());//.Where(c=>c.Booking.Specialist.Id == id));
            Assert.AreEqual(expectedValue, currentValue);
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:53,代码来源:BookingServiceTest.cs


注:本文中的Call.AsQueryable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。