本文整理汇总了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);
}
示例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);
}
示例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>());
}
示例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);
}
示例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);
}