public void Get_All_Blogs()
        {
            BlogsController controller = new BlogsController(new Initialize());
            ViewResult      blogs      = controller.Index() as ViewResult;

            Assert.IsNotNull(blogs);
        }
Ejemplo n.º 2
0
        public void Index_Returns_View()
        {
            var blogController = new BlogsController();
            var result         = blogController.Index();

            Assert.IsType <ViewResult>(result);
        }
Ejemplo n.º 3
0
 public void Index_NotFound_By_StoreId()
 {
     using (var context = new ApplicationDbContext(options))
     {
         var dataProtectionProvider = new EphemeralDataProtectionProvider();
         blogsController = new BlogsController(context, dataProtectionProvider, mockHttpContextAccessor.Object, mockEnvironment.Object);
         var resultTask = blogsController.Index();
         resultTask.Wait();
         var response = resultTask.Result as NotFoundResult;
         Assert.AreEqual((int)HttpStatusCode.NotFound, response.StatusCode);
     }
 }
Ejemplo n.º 4
0
 public void Index_By_StoredId()
 {
     using (var context = new ApplicationDbContext(options))
     {
         var dataProtectionProvider = new EphemeralDataProtectionProvider();
         blogsController = new BlogsController(context, dataProtectionProvider, mockHttpContextAccessor.Object, mockEnvironment.Object);
         var resultTask = blogsController.Index(1);
         resultTask.Wait();
         var model = (List <Blogs>)((ViewResult)resultTask.Result).Model;
         Assert.IsNotNull(resultTask.Result);
         Assert.AreEqual(1, model.Count);
     }
 }
Ejemplo n.º 5
0
        public void Index()
        {
            // Arrange
            var controller = new BlogsController(_blogService);

            // Act
            var result = controller.Index().Result as ViewResult;
            var model  = result.Model as List <Blog>;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, model.Count);
        }
Ejemplo n.º 6
0
        public void Alphabetize_The_Results_By_Company_Name()
        {
            Context.Blogs.Add(new Blog()
            {
                CompanyName = "B"
            });
            Context.Blogs.Add(new Blog()
            {
                CompanyName = "A"
            });

            var target = new BlogsController(Context);

            var viewModel = target.Index().GetResult <IEnumerable <Blog> >();

            viewModel.First().CompanyName.ShouldBe("A");
        }
Ejemplo n.º 7
0
        public async Task IndexBlogsController()
        {
            var context    = GetInMemoryDbMetData();
            var controller = new BlogsController(context, _hostingEnvironment);

            var result = await controller.Index();

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <List <Blog> >(viewResult.ViewData.Model);

            //Test Blog 1
            Assert.Equal("Season", model[0].Category);
            Assert.Equal("Season", model[1].Category);

            //Test Blog 2
            Assert.Equal("Winter 2018", model[0].Title);
            Assert.Equal("Summer 2018", model[1].Title);
            Assert.Equal(2, model.Count);
            Assert.NotNull(viewResult);
        }
        public void getAllBlogs()
        {
            List <Blog> fakeBlogs = new List <Blog> {
                new Blog {
                    BlogOwner = "test1", BlogTitle = "test1"
                },
                new Blog {
                    BlogOwner = "test2", BlogTitle = " test2"
                }
            };

            _repo.Setup(x => x.getAllBlogs()).Returns(fakeBlogs);
            var controller = new BlogsController(_repo.Object);

            var result = controller.Index() as ViewResult;

            CollectionAssert.AllItemsAreInstancesOfType((ICollection)result.ViewData.Model, typeof(Blog));
            Assert.IsNotNull(result, "View result is null.");
            var op = result.ViewData.Model as List <Blog>;

            Assert.AreEqual(2, op.Count, "Got wrong number of Blogs");
        }
        public async void Index_ActionExecutes_ReturnView()
        {
            var result = await _controller.Index();

            Assert.IsType <ViewResult>(result);
        }