Ejemplo n.º 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());
        }
        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);
        }