public void Index() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
public void About() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.About() as ViewResult; // Assert Assert.AreEqual("Your application description page.", result.ViewBag.Message); }
public void TestUploadExcelFile() { //We'll need mocks of context, request and fake file var request = new Mock<HttpRequestBase>(); var context = new Mock<HttpContextBase>(); var postedfile = new Mock<HttpPostedFileBase>(); //Someone is going to ask for Request.File and we'll need a mock (fake) of that var postedFilesKeyCollection = new Mock<HttpFileCollectionBase>(); var fakeFileKeys = new List<string>() { "file" }; //Code being tested for implementation HomeController controller = new HomeController(); ViewResult result = controller.UploadFiles() as ViewResult; var uploadResult = result.ViewData.Model as List<ViewDataUploadFilesResult>; Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.doc"), uploadedResult[0].Name); Assert.AreEqual(8192, uploadedResult[0].Length); }