コード例 #1
0
        public void GetSummary_ReturnsSummaryObject()
        {
            //arrange
            var repository = new Mock <IUsersRepository>();
            var usersList  = new List <User>
            {
                new User {
                    Email = "*****@*****.**"
                },
                new User {
                    Email = "*****@*****.**"
                },
                new User {
                    Email = "*****@*****.**"
                },
                new User {
                    Email = "*****@*****.**", Temp = true
                }
            };

            repository.Setup(r => r.Users).Returns(usersList.AsQueryable());

            var userManagement = new UserManagementController(repository.Object);

            //act
            var result = userManagement.Summary() as ViewResult;

            //post
            var model = result.ViewData.Model as UserSummaryModel;

            Assert.That(model, Is.Not.Null);
            Assert.That(model.TotalRegisteredUsers, Is.EqualTo(4));
            Assert.That(model.TempUsers, Is.EqualTo(1));
        }