本文整理汇总了C#中UserRepository.GetAvailableUsers方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetAvailableUsers方法的具体用法?C# UserRepository.GetAvailableUsers怎么用?C# UserRepository.GetAvailableUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.GetAvailableUsers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAvailableUsers_ShouldNotReturnUsers_WhoHasAcceptedToAnswer_ButHasNotCompletedIt
public void GetAvailableUsers_ShouldNotReturnUsers_WhoHasAcceptedToAnswer_ButHasNotCompletedIt()
{
//Arrange
var dbMock = new Mock<IRadvillContext>();
var userOne = new User
{
ID = 1,
Connected = true
};
var userDbSet = new FakeDbSet<User>
{
userOne
};
dbMock.Setup(x => x.Users).Returns(userDbSet);
var pendingQuestion = new PendingQuestion
{
ID = 1,
User = userOne,
Answer = null,
Status = true
};
var pendingQuestionDbSet = new FakeDbSet<PendingQuestion>
{
pendingQuestion
};
dbMock.Setup(x => x.PendingQuestions).Returns(pendingQuestionDbSet);
dbMock.Setup(x => x.Set<User>()).Returns(userDbSet);
var userRepository = new UserRepository(dbMock.Object);
//Act
var result = userRepository.GetAvailableUsers();
//Assert
Assert.That(result, Is.Not.Null);
Assert.That(result.Count(), Is.EqualTo(0));
}
示例2: GetAvailableUsers_ShouldOnlyReturnConnectedUsers
public void GetAvailableUsers_ShouldOnlyReturnConnectedUsers()
{
//Arrange
var dbMock = new Mock<IRadvillContext>();
var userOne = new User
{
ID = 1,
Connected = false
};
var userTwo = new User
{
ID = 2,
Connected = true
};
var userThree = new User
{
ID = 3,
Connected = true
};
var userFour = new User
{
ID = 4,
Connected = true
};
var userDbSet = new FakeDbSet<User>
{
userOne,
userTwo,
userThree,
userFour
};
dbMock.Setup(x => x.Users).Returns(userDbSet);
dbMock.Setup(x => x.PendingQuestions).Returns(new FakeDbSet<PendingQuestion>());
dbMock.Setup(x => x.Set<User>()).Returns(userDbSet);
var userRepository = new UserRepository(dbMock.Object);
//Act
var result = userRepository.GetAvailableUsers();
//Assert
Assert.That(result, Is.Not.Null);
Assert.That(result.Count(), Is.EqualTo(3));
Assert.That(result.Any(x => !x.Connected), Is.False);
}
示例3: GetAvailableUsers_ShouldReturnUsers_WhoIsntAnswereringAQuestion
public void GetAvailableUsers_ShouldReturnUsers_WhoIsntAnswereringAQuestion()
{
//Arrange
var dbMock = new Mock<IRadvillContext>();
var userOne = new User
{
ID = 1,
Connected = true
};
var userTwo = new User
{
ID = 2,
Connected = true
};
var userDbSet = new FakeDbSet<User>
{
userOne,
userTwo
};
dbMock.Setup(x => x.Users).Returns(userDbSet);
var pendingQuestion = new PendingQuestion
{
ID = 1,
User = userOne
};
var pendingQuestionDbSet = new FakeDbSet<PendingQuestion>
{
pendingQuestion
};
dbMock.Setup(x => x.PendingQuestions).Returns(pendingQuestionDbSet);
dbMock.Setup(x => x.Set<User>()).Returns(userDbSet);
var userRepository = new UserRepository(dbMock.Object);
//Act
var result = userRepository.GetAvailableUsers();
//Assert
Assert.That(result, Is.Not.Null);
Assert.That(result.Count(), Is.EqualTo(1));
Assert.That(result.First().ID, Is.EqualTo(userTwo.ID));
}