public void ReturnViewWithFirstModelInProvidedCollectionWhenParameterIdIsNull() { // Arrange var comicServiceMock = new Mock <IComicService>(); Comic firstComic = new Comic() { Name = "Flash", Id = 1 }; Comic secondComic = new Comic() { Name = "Batman", Id = 2 }; var listOfComics = new List <Comic>() { firstComic, secondComic }; comicServiceMock.Setup(x => x.GetAllComics()).Returns(listOfComics.AsQueryable); // Act var comicController = new ComicShop.Web.Controllers.ComicsController(comicServiceMock.Object); //Assert comicController .WithCallTo(c => c.Details(null)) .ShouldRenderDefaultView() .WithModel <Comic>(model => { Assert.IsInstanceOf(typeof(Comic), model); Assert.AreEqual(model, firstComic); }); }
public void ReturnViewWithListOfCorrectModelsWhenThereAreAnyExisting() { // Arrange var comicServiceMock = new Mock <IComicService>(); Comic firstComic = new Comic() { Name = "Flash" }; Comic secondComic = new Comic() { Name = "Batman" }; var listOfComics = new List <Comic>() { firstComic, secondComic }; // Act var comicController = new ComicShop.Web.Controllers.ComicsController(comicServiceMock.Object); //Assert comicController .WithCallTo(c => c.Index(1)) .ShouldRenderDefaultView() .WithModel <PagedList <ComicViewModel> >(model => { Assert.IsInstanceOf(typeof(PagedList <ComicViewModel>), model); }); }
public void ReturnsAnInstanceWhenParameterIsNotNull() { // Arrange var comicServiceMock = new Mock <IComicService>(); // Act var comicsController = new ComicShop.Web.Controllers.ComicsController(comicServiceMock.Object); // Assert Assert.IsNotNull(comicsController); }