コード例 #1
0
        public void GetBlogs_Should_Return_BlogResponse_List()
        {
            mockService.Setup(service => service.GetBlogs())
            .Returns(GetTestBlogs());
            mockMapper.Setup(mapper => mapper.Map <BlogResponse>(It.IsAny <Blog>()))
            .Returns(new BlogResponse());

            var result = controller.GetBlogs();

            var blogs = Assert.IsAssignableFrom <IEnumerable <BlogResponse> >(result.Value);

            Assert.Equal(2, blogs.ToList().Count);
        }
コード例 #2
0
        public void GetShouldReturn2Blogs()
        {
            // arrange
            var _blogsController = new BlogsController();
            var expectedResults  = _blogService.GetBlogs();

            // act
            var results = _blogsController.GetBlogs();


            // assert
            Assert.AreEqual(expectedResults.Count(), results.Count());
        }
コード例 #3
0
        public void GetBlogsReturnsBlogs()
        {
            // Arrange

            // Act
            var content = _controller.GetBlogs();

            // Assert
            // Verify that GetAll is called just once
            // Verify that the correct number of blogs are returned
            _blogRepositoryMock.Verify(p => p.GetAll(), Times.Once);
            Assert.AreEqual(content.Count(), _blogs.Length);
        }
コード例 #4
0
        public void GetShouldReturnAllBlogs()
        {
            // arrange
            var _blogsController = new BlogsController();
            IEnumerable <Blog> expectedResults = _blogService.GetBlogs();

            // act
            IEnumerable <Blog> results = _blogsController.GetBlogs();

            // assert
            var er = expectedResults.ToList();
            var r  = results.ToList();

            for (int i = 0; i < r.Count; i++)
            {
                Blog rid = r.Where(x => x.ID == er[i].ID).FirstOrDefault();
                Assert.AreEqual <Blog>(er[i], rid);
            }

            // CollectionAssert.AreEqual(results.ToList(), results.ToList());
        }