public void Test_PhotoGallery_Model_Type() { //This test checks that the PhotoController _PhotoGallery action passes a list of Photos to the view var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo(), new Photo(), new Photo(), new Photo() }.AsQueryable(); var controller = new PhotoController(context); var result = controller._PhotoGallery() as PartialViewResult; Assert.AreEqual(typeof(List<Photo>), result.Model.GetType()); }
public void Test_PhotoGallery_No_Parameter() { //This test checks that, when you call the _PhotoGallery action with no //parameter, all the photos in the context are returned var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo(), new Photo(), new Photo(), new Photo() }.AsQueryable(); var controller = new PhotoController(context); var result = controller._PhotoGallery() as PartialViewResult; var modelPhotos = (IEnumerable<Photo>)result.Model; Assert.AreEqual(4, modelPhotos.Count()); }