Exemplo n.º 1
0
        public void GetNews()
        {
            IEnumerable <UserPost> userPosts = new List <UserPost>();

            _postsRepoMock.Setup(m => m.GetNews(_loginUser.UserId)).Returns(userPosts);
            PostController    controller = new PostController(_postsRepoMock.Object, _loginUser);
            PartialViewResult result     = controller.GetNews();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ViewName == "_Posts");
            Assert.IsNotNull(result.Model);
            Assert.IsTrue(result.Model is IEnumerable <UserPost>);
            Assert.IsNotNull(controller.ViewBag.VisibilityOptions);
            Assert.IsNotNull(controller.ViewBag.Scripts);
            Assert.IsTrue(controller.ViewBag.VisibilityOptions is IEnumerable <EnumVM>);
            Assert.IsTrue(controller.ViewBag.Scripts is IEnumerable <String>);
            CollectionAssert.AreEqual(userPosts.ToList(), (result.Model as IEnumerable <UserPost>).ToList());
        }