public async void TagsController_Index() { //TO DO write test to check usagecnt var ctrlr = new TagsController(_dbContext); var result = await ctrlr.Index(); var resultView = Assert.IsType <ViewResult>(result); var viewModel = Assert.IsType <List <TagViewModel> >(resultView.ViewData.Model).ToList(); Assert.True(1 <= viewModel.Count(d => d.TagName == "stuff")); Assert.True(1 <= viewModel.Count(d => d.TagName == "category")); Assert.True(1 <= viewModel.Count(d => d.TagName == "interest")); }
private async Task DeleteAllTagsAsync() { var c = new TagsController(_context); var index = await c.Index(); var list = (Microsoft.AspNetCore.Mvc.ViewResult)index; var IndexTagViewModel = (IndexTagViewModel)list.Model; foreach (var tag in IndexTagViewModel.TagModels) { var result = await c.DeleteConfirmed(tag.TagID, tag.ActivityID); } }
public void TagsController_Index() { //Arrange var tagsRepo = new FakeRepository <Tag>(e => e.TagID); //Act var controller = new TagsController(tagsRepo); controller.ControllerContext = new ControllerContext(Context.Object, new RouteData(), controller); var result = controller.Index() as ViewResult; //Assert Assert.IsNotNull(result); }