コード例 #1
0
        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:"));
        }
コード例 #2
0
            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);
            }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }