public void Image_Get_returns_HttpNotFound_result_when_file_does_not_exist() { // Arrange string filepath = null; LayoutManagerMock.Setup(x => x.Exists("file.jpg", out filepath)).Returns(false); // Act var result = Sut.Image(CompanyId, "file.jpg"); // Assert Assert.IsInstanceOf <HttpNotFoundResult>(result); }
public void Image_Get_asks_for_image_file() { // Arrange string filepath = "path/to/file.jpg"; LayoutManagerMock.Setup(x => x.Exists("file.jpg", out filepath)).Returns(true); // Act var result = Sut.Image(CompanyId, "file.jpg"); // Assert Assert.IsInstanceOf <FilePathResult>(result); var filePathResult = (FilePathResult)result; Assert.AreEqual("path/to/file.jpg", filePathResult.FileName); }
public void Index_Post_saves_uploaded_layouts_and_redirects_to_Index() { // Arrange var files = new[] { new PostedFileStub("layout.jpg") }; // Act var result = Sut.Index(CompanyId, files); // Assert LayoutManagerMock.Verify(x => x.Save(It.IsAny <HttpPostedFileBase>())); Assert.IsInstanceOf <RedirectToRouteResult>(result); var redirect = (RedirectToRouteResult)result; Assert.AreEqual("Index", redirect.RouteValues["action"]); Assert.AreEqual(CompanyId, redirect.RouteValues["id"]); }
public void Delete_Post_deletes_file() { var result = Sut.Delete(CompanyId, "layout.jpg"); LayoutManagerMock.Verify(x => x.Delete("layout.jpg")); }