示例#1
0
        public void index_should_return_view_and_viewmodel_with_both_user_types()
        {
            // Arrange
            User admin = new User()
            {
                Id = Guid.NewGuid()
            };

            _userService.Users.Add(admin);

            User editor = new User()
            {
                Id = Guid.NewGuid()
            };

            _userService.Users.Add(editor);

            // Act
            ViewResult result = _controller.Index() as ViewResult;

            // Assert
            Assert.That(result, Is.Not.Null, "ViewResult");
            List <IEnumerable <UserViewModel> > model = result.ModelFromActionResult <List <IEnumerable <UserViewModel> > >();

            Assert.That(model, Is.Not.Null, "model");
            Assert.That(model.Count, Is.EqualTo(2));
        }
        public void GetIndex_ReturnsView()
        {
            //arrange
            var repository     = new Mock <IUsersRepository>();
            var userManagement = new UserManagementController(repository.Object);

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

            //assert
            Assert.That(result, Is.Not.Null);
        }
示例#3
0
        public async Task ReturnIndexViewWhenInvoked()
        {
            //Arrange
            var userServiceMock           = new Mock <IUserService>();
            var twitterAccountServiceMock = new Mock <ITwitterAccountService>();
            var tweetServiceMock          = new Mock <ITweetService>();

            var controller = new UserManagementController
                             (
                userServiceMock.Object,
                twitterAccountServiceMock.Object,
                tweetServiceMock.Object
                             );

            //Act & Assert
            var result = await controller.Index() as ViewResult;

            Assert.AreEqual("Index", result.ViewName);
        }