public void ShouldLoadFromDiskIfPathNotInCache()
        {
            string contents = String.Empty;
            var    cache    = new CachingViewFolder(ROOT_VIEW_PATH);
            var    content  = cache.GetViewSource("Shared\\Application.spark");

            using (TextReader reader = new StreamReader(content.OpenViewStream()))
                contents = reader.ReadToEnd();

            Assert.That(contents.Contains("no header by default"));
        }
Ejemplo n.º 2
0
        public void ShouldLoadFromDiskIfPathNotInCache()
        {
            string contents = String.Empty;
            var cache = new CachingViewFolder(ROOT_VIEW_PATH);
            var content = cache.GetViewSource("Shared\\Application.spark");

            using (TextReader reader = new StreamReader(content.OpenViewStream()))
                contents = reader.ReadToEnd();

            Assert.That(contents.Contains("no header by default"));
        }
Ejemplo n.º 3
0
        public void ShouldAllowCacheContentToBeReplaced()
        {
            string path = "Shared\\test.spark";
            string contents = String.Empty;
            var cache = new CachingViewFolder(ROOT_VIEW_PATH);
            cache.Add(path);
            string newContent = "This is new content";

            cache.SetViewSource(path, newContent);
            var content = cache.GetViewSource(path);
            using (TextReader reader = new StreamReader(content.OpenViewStream()))
                contents = reader.ReadToEnd();

            Assert.That(contents.Contains(newContent));
        }
        public void ShouldAllowCacheContentToBeReplaced()
        {
            string path     = "Shared\\test.spark";
            string contents = String.Empty;
            var    cache    = new CachingViewFolder(ROOT_VIEW_PATH);

            cache.Add(path);
            string newContent = "This is new content";

            cache.SetViewSource(path, newContent);
            var content = cache.GetViewSource(path);

            using (TextReader reader = new StreamReader(content.OpenViewStream()))
                contents = reader.ReadToEnd();

            Assert.That(contents.Contains(newContent));
        }
Ejemplo n.º 5
0
        public void ShouldBeAbleToEvictViewChunksWhenChangedInMemory()
        {
            string key = "Shared\\test.spark";
            string content = "<var x='5'/>";
            var viewFolder = new CachingViewFolder(Path.GetFullPath(ROOT_VIEW_PATH));

            _mockProjectExplorer.Expect(x => x.GetViewFolder()).Return(viewFolder);

            var viewExplorer = new ViewExplorer(_mockProjectExplorer, key);
            var localVars = viewExplorer.GetLocalVariables();
            Assert.That(localVars.Count, Is.EqualTo(5));

            content += "<var y='25' />";
            _mockProjectExplorer.Expect(x => x.SetViewContent(key, content))
                .WhenCalled(x => viewFolder.SetViewSource(key, content));

            viewExplorer.InvalidateView(content);
            localVars = viewExplorer.GetLocalVariables();
            Assert.That(localVars.Count, Is.EqualTo(2));
        }
Ejemplo n.º 6
0
        public void ShouldBeAbleToEvictViewChunksWhenChangedInMemory()
        {
            string key        = "Shared\\test.spark";
            string content    = "<var x='5'/>";
            var    viewFolder = new CachingViewFolder(Path.GetFullPath(ROOT_VIEW_PATH));

            _mockProjectExplorer.Expect(x => x.GetViewFolder()).Return(viewFolder);

            var viewExplorer = new ViewExplorer(_mockProjectExplorer, key);
            var localVars    = viewExplorer.GetLocalVariables();

            Assert.That(localVars.Count, Is.EqualTo(5));

            content += "<var y='25' />";
            _mockProjectExplorer.Expect(x => x.SetViewContent(key, content))
            .WhenCalled(x => viewFolder.SetViewSource(key, content));

            viewExplorer.InvalidateView(content);
            localVars = viewExplorer.GetLocalVariables();
            Assert.That(localVars.Count, Is.EqualTo(2));
        }