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


C# UserRepository.GetAvailableUsers方法代码示例

本文整理汇总了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));
        }
开发者ID:nesheimroger,项目名称:Radvill,代码行数:43,代码来源:UserRepositoryTests.cs

示例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);
        }
开发者ID:nesheimroger,项目名称:Radvill,代码行数:50,代码来源:UserRepositoryTests.cs

示例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));
        }
开发者ID:nesheimroger,项目名称:Radvill,代码行数:49,代码来源:UserRepositoryTests.cs


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