public void GetTreeDataTest() { // Arrange var home = new HomeController(); FakeHttpContextHelper.SetFakeControllerContext(home); home.Session["AlreadyPopulated"] = false; // Act var result = (JsonResult)home.GetTreeData(); // Assert Assert.IsFalse(result.Data.ToString().Contains("Error retrieving file tree:")); }
public void IndexTest() { // Arrange var home = new HomeController(); FakeHttpContextHelper.SetFakeControllerContext(home); home.Session["AlreadyPopulated"] = false; // Act var result = home.Index("www.test.com") as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.ViewName); }
public void GetFileContentMultilingualTest() { // Arrange var home = new HomeController(); FakeHttpContextHelper.SetFakeControllerContext(home); // Act var result = (JsonResult)home.GetFileContent(RootPath + "\\testDoNotEdit.htm", "2"); // Assert const string expected = "{ BodyContent = <html"; var resultStart = result.Data.ToString().Substring(0, 21); Assert.AreEqual(expected, resultStart); }
public void SaveFileContentTest() { // Arrange const string fileName = "TestFileName.htm"; var home = new HomeController(); FakeHttpContextHelper.SetFakeControllerContext(home); home.Session["AlreadyPopulated"] = false; File.Create(RootPath + fileName).Close(); // Act home.SaveFileContent(RootPath + fileName, FileContent, "TestHtmlTitle"); // Assert Assert.IsTrue(File.Exists(RootPath + fileName)); // Cleanup File.Delete(RootPath + fileName); }