public async Task Index_ReturnsAViewResult_WithAListOfBrainstormSessions() { // Arrange var mockTagRepo = new Mock <ITagService>(); mockTagRepo.Setup(repo => repo.GetAllTagsAsync()) .ReturnsAsync(GetTagsTest()); var autoMapperConfiguration = new MapperConfiguration(cfg => { cfg.CreateMap <Tag, TagResponse>(); } ); var mapper = autoMapperConfiguration.CreateMapper(); var controller = new TagsController(mapper, mockTagRepo.Object); // Act var result = await controller.GetAll(); // Assert var objectResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsAssignableFrom <List <TagResponse> >(objectResult.Value); Assert.Equal(2, model.Count); }
public void Get_all_should_return_tags_list() { // arrange var tagsRepository = new Mock <ITagRepository>(); var tagsList = TestUtil.CreateTagsList(); tagsRepository.Setup(c => c.GetAll()).Returns(tagsList); // act var controller = new TagsController(tagsRepository.Object); var result = controller.GetAll(); // assert //result .Count().Should().Be(8); //result.First().Name.Should().Be("Ball Handling"); tagsRepository.VerifyAll(); }