コード例 #1
0
        public void ResultsAreTheSame()
        {
            IViewSourceLoader loader = new FileSystemViewSourceLoader("MvcContrib.Tests.Views");
            IViewFolder wrapper = new ViewSourceLoaderWrapper(loader);

            Assert.AreEqual(loader.HasView("Home\\foreach.spark"), wrapper.HasView("Home\\foreach.spark"));
            Assert.AreEqual(loader.HasView("Home\\nosuchfile.spark"), wrapper.HasView("Home\\nosuchfile.spark"));

            var loaderViews = loader.ListViews("Shared");
            var wrapperViews = wrapper.ListViews("Shared");
            Assert.AreEqual(loaderViews.Count(), wrapperViews.Count);

            foreach (var viewName in loaderViews)
            {
                Assert.That(wrapperViews.Contains(viewName));
            }

            var loaderView = loader.GetViewSource("Home\\foreach.spark");
            var wrapperView = wrapper.GetViewSource("Home\\foreach.spark");

            Assert.AreEqual(loaderView.LastModified, wrapperView.LastModified);

            var loaderReader = new StreamReader(loaderView.OpenViewStream());
            var wrapperReader = new StreamReader(wrapperView.OpenViewStream());
            Assert.AreEqual(loaderReader.ReadToEnd(), wrapperReader.ReadToEnd());
        }
コード例 #2
0
        public void GetViewSource_ReturnsNull_For_Non_Existing_Views()
        {
            var viewSourceLoader = new FileSystemViewSourceLoader();

            if (viewSourceLoader.ViewRootDirectory == null)
            {
                viewSourceLoader.ViewRootDirectory = "C:\\";
            }

            Assert.IsNull(viewSourceLoader.GetViewSource("D:\\MyLovelyView"));
        }
コード例 #3
0
        public void Can_Add_And_Remove_Listeners()
        {
            var viewSourceLoader = new FileSystemViewSourceLoader("C:\\");

            FileSystemEventHandler handler = delegate { };

            viewSourceLoader.ViewRootDirectoryChanged += handler;
            viewSourceLoader.ViewRootDirectoryChanged -= handler;
            viewSourceLoader.ViewRootDirectoryChanged += handler;
            viewSourceLoader.ViewRootDirectoryChanged -= handler;
        }
コード例 #4
0
        public void ListViews_Returns_Empty_Array_For_Invalid_Directory()
        {
            var viewSourceLoader = new FileSystemViewSourceLoader();

            if (viewSourceLoader.ViewRootDirectory == null)
            {
                viewSourceLoader.ViewRootDirectory = "C:\\";
            }

            string[] views = viewSourceLoader.ListViews("MyViewDir");

            Assert.IsNotNull(views);
            Assert.AreEqual(0, views.Length);
        }
コード例 #5
0
        public void HasView_ReturnsFalse_For_Non_Existing_Views()
        {
            var viewSourceLoader = new FileSystemViewSourceLoader("C:\\");

            Assert.IsFalse(viewSourceLoader.HasView("D:\\MyLovelyView"));
        }