本文整理汇总了C#中Profile.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# Profile.AsQueryable方法的具体用法?C# Profile.AsQueryable怎么用?C# Profile.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile.AsQueryable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProfileByUserId_AnyId_CallsQueryMethodOfRepository
public void GetProfileByUserId_AnyId_CallsQueryMethodOfRepository()
{
var settingsMock = new Mock<ISettings>();
var componentsMock = new Mock<IComponents>();
var repositoryMock = new Mock<IRepository>();
var uowMock = new Mock<IUnitOfWork>();
var serviceLocatorMock = new Mock<IServiceLocator>();
serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
.Returns(repositoryMock.Object);
serviceLocatorMock.Setup(x => x.GetInstance<IUnitOfWork>())
.Returns(uowMock.Object);
ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);
// Arrange
string token = Guid.NewGuid().ToString();
Guid id = Guid.NewGuid();
Guid profileId= Guid.NewGuid();
User user = new User()
{
Id = id,
CreatedDate = DateTime.Now
};
Profile profile = new Profile()
{
Id =profileId,
User = user
};
Profile[] profiles = new Profile[] { profile };
repositoryMock.Setup(r => r.Query<Profile>()).Returns(profiles.AsQueryable());
repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object);
// Act
var userService = new UserService(uowMock.Object,repositoryMock.Object, settingsMock.Object, componentsMock.Object);
ProfileDto actuaProfile = userService.GetProfileByUserId(id);
// Assert
repositoryMock.Verify(repo => repo.Query<Profile>());
Assert.AreEqual(actuaProfile.Id, profile.Id);
}