예제 #1
0
        public void TagControllerTests_Empty_Repository_Returns_No_Tags()
        {
            //Arrange
            var repo = Substitute.For<IRepository>();
            repo.Find(Arg.Any<SearchTagsByNameQuery>()).Returns(x => Enumerable.Empty<Tag>());
            var controller = new TagController(repo);

            //Act
            var result = controller.Index() as JsonResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            Assert.IsFalse(((IEnumerable<object>) result.Data).Any());
        }
예제 #2
0
        public void TagControllerTests_GetAll_Returns_Entire_Repository()
        {
            //Arrange
            var repo = Substitute.For<IRepository>();
            repo.Find(Arg.Any<SearchTagsByNameQuery>())
                .Returns(Enumerable
                                       .Range(0, 5)
                                       .Select(x => new Tag
                                                        {
                                                            Name = x.ToString()
                                                        })
                                       .AsQueryable());
            var controller = new TagController(repo);

            //Act
            var result = controller.Index() as JsonResult;

            //Assert
            Assert.IsTrue(((IEnumerable<object>)result.Data).Count() == 5);
        }