public void Test_DisplayByTitle_Return_Null() { //This test checks that the PhotoController DisplayByTitle action returns //HttpNotFound when you request a title that doesn't exist var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo { PhotoID = 1, Title = "Photo1" }, new Photo { PhotoID = 2, Title = "Photo2" }, new Photo { PhotoID = 3, Title = "Photo3" }, new Photo { PhotoID = 4, Title = "Photo4" } }.AsQueryable(); var controller = new PhotoController(context); var result = controller.DisplayByTitle("NonExistentTitle"); Assert.AreEqual(typeof(HttpNotFoundResult), result.GetType()); }
public void Test_PhotoGallery_Model_Type() { var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo(), new Photo(), new Photo(), new Photo() }.AsQueryable(); var controller = new PhotoController(context); context.Photos = new[] { new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var result = controller._PhotoGallery() as PartialViewResult; Assert.AreEqual(typeof(List <Photo>), result.Model.GetType()); }
public void Test_GetImage_Return_Type() { //This test checks that the PhotoController GetImage action returns a FileResult var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var controller = new PhotoController(context); var result = controller.GetImage(1) as ActionResult; Assert.AreEqual(typeof(FileContentResult), result.GetType()); }
public void Test_GetImage_Return_Type() { var context = new FakePhotoSharingContext { Photos = new[] { new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable() }; var controller = new PhotoController(context); var result = controller.GetImage(1); Assert.AreEqual( result.GetType(), typeof(FileContentResult) ); }
public void Test_DisplayByTitle_Return_Photo() { //This test checks that the PhotoController DisplayByTitle action returns the right photo var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo { PhotoID = 1, Title = "Photo1" }, new Photo { PhotoID = 2, Title = "Photo2" }, new Photo { PhotoID = 3, Title = "Photo3" }, new Photo { PhotoID = 4, Title = "Photo4" } }.AsQueryable(); var controller = new PhotoController(context); var result = controller.DisplayByTitle("Photo2") as ViewResult; var resultPhoto = (Photo)result.Model; Assert.AreEqual(2, resultPhoto.PhotoID); }
public void TestMethod1() { var context = new FakePhotoSharingContext(); var controller = new HomeController(); ViewResult result = controller.Index(); Assert.AreEqual("Index", result.ViewName); }
public void Test_Index_Return_View() { var fps = new FakePhotoSharingContext(); var controller = new PhotoController(fps); var returnResult = controller.Index() as ViewResult; Assert.AreEqual(returnResult.ViewName, "Index"); }
public void Test_Index_Return_View() { var context = new FakePhotoSharingContext(); var controller = new PhotoController(context); var result = controller.Index() as ViewResult; Assert.AreEqual("Index", result.ViewName); }
public void Test_Index_Return_View() { //This test checks that the PhotoController Index action returns the Index View var context = new FakePhotoSharingContext(); var controller = new PhotoController(context); var result = controller.Index() as ViewResult; Assert.AreEqual("Index", result.ViewName); }
public void Test_PhotoGallery_Model_Type() { 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.GetType()); }
public void Test_PhotoGallery_Int_Parameter() { 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(3) as PartialViewResult; var modelPhotos = (IEnumerable <Photo>)result.Model; Assert.AreEqual(3, modelPhotos.Count()); }
public void Test_PhotoGallery_Model_Type() { var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo(), new Photo(), new Photo(), new Photo() }.AsQueryable(); var controller = new PhotoController(context); }
public void Test_Index_Return_View() { var context = new FakePhotoSharingContext(); PhotoController photoController = new PhotoController(context); var result = photoController.Index(); Assert.AreEqual("Index", ((ViewResult)result).ViewName); //Optional //var context = new FakePhotoSharingContext(); //var controller = new PhotoController(context); //var result = controller.Index() as ViewResult; //Assert.AreEqual("Index", result.ViewName); }
public void Test_GetImage_Return_Type() { //This test checks that the PhotoController GetImage action returns a FileResult var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo{ PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo{ PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo{ PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo{ PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var controller = new PhotoController(context); var result = controller.GetImage(1) as ActionResult; Assert.AreEqual(typeof(FileContentResult), result.GetType()); }
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_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()); }
public void Test_Photo_Gallery_Int_Parameter() { var context = new FakePhotoSharingContext { Photos = new[] { new Photo(), new Photo(), new Photo(), new Photo() }.AsQueryable() }; var controller = new PhotoController(context); var result = controller._PhotoGallery(3) as PartialViewResult; Assert.AreEqual( (result.Model as IEnumerable <Photo>).Count(), 3 ); }
public void Test_PhotoGallery_Int_Parameter() { //This test checks that, when you call the _PhotoGallery action with a //parameter, some of 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(3) as PartialViewResult; var modelPhotos = (IEnumerable <Photo>)result.Model; Assert.AreEqual(3, modelPhotos.Count()); }
public void Test_GetImage_Return_Type() { var context = new FakePhotoSharingContext(); context.Photos = new[] { new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var controller = new PhotoController(context); }
public void Test_GetImage_ReturnType() { var fps = new FakePhotoSharingContext(); fps.Photos = new[] { new Photo { PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new Photo { PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var controller = new PhotoController(fps); var photo = controller.GetImage(2) as ActionResult; Assert.AreEqual(photo.GetType(), typeof(FileContentResult)); }
public void Test_PhotoGallery_Int_Parameter(int num) { var fps = new FakePhotoSharingContext(); //Create and add 4 photo objects to fps new instance and pass it to //the controller constructor. fps.Photos = new[] { new Photo { }, new Photo { }, new Photo { }, new Photo { } }.AsQueryable(); var controller = new PhotoController(fps); var retResult = controller._PhotoGallery(3) as PartialViewResult; //cast retResult.Model property as an IEnumerable<Photo> collection var modelPhotos = (IEnumerable <Photo>)retResult.Model; //check that the number of photos in the collection is 3 Assert.AreEqual(3, modelPhotos.Count()); }
public void Test_GetImage_Return_Type() { // var controller = new PhotoController(); var context = new FakePhotoSharingContext(); context.Photos = new[] { new PhotoSharingApp.model.Photo { PhotoId = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new PhotoSharingApp.model.Photo { PhotoId = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new PhotoSharingApp.model.Photo { PhotoId = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, new PhotoSharingApp.model.Photo { PhotoId = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } }.AsQueryable(); var controller = new PhotoController(context); var result = controller.GetImage(1) as ActionResult; Assert.AreEqual(typeof(FileContentResult), result.GetType()); }
public void TestInitialize() { context = new FakePhotoSharingContext(); controller = new PhotoController(context); }
/*[TestMethod] * public void Test_Add_Favorite_Int_Parameter() * { * context.Photos = new[] { * new Photo{ PhotoID = 1, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, * new Photo{ PhotoID = 2, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, * new Photo{ PhotoID = 3, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" }, * new Photo{ PhotoID = 4, PhotoFile = new byte[1], ImageMimeType = "image/jpeg" } * }.AsQueryable(); * //controller.Session["Favorites"]=Ses * var result = controller.AddFavorite(2); * Assert.AreEqual("The picture has been added to your favorites", result.Content); * }*/ public void TestCleanup() { controller = null; context = null; }