コード例 #1
0
        public void EnumerateItems_WithNoFilesInRoot_ReturnsEmptySequence()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();

            // Act
            var result = projectSystem.EnumerateItems("/");

            // Assert
            Assert.Empty(result);
        }
コード例 #2
0
        public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();

            // Act
            var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml", fileKind: null);

            // Assert
            Assert.False(actual.Exists);
        }
コード例 #3
0
        public void GetItem_ReturnsItemAddedToNestedDirectory(string path)
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();
            var projectItem   = new TestRazorProjectItem(path);

            // Act
            projectSystem.Add(projectItem);
            var actual = projectSystem.GetItem(path, fileKind: null);

            // Assert
            Assert.Same(projectItem, actual);
        }
コード例 #4
0
        public void GetItem_ReturnsNotFound_IfFileDoesNotExistInRoot()
        {
            // Arrange
            var path          = "/root-file.cshtml";
            var projectSystem = new VirtualRazorProjectFileSystem();

            // Act
            projectSystem.Add(new TestRazorProjectItem("/different-file.cshtml"));
            var result = projectSystem.GetItem(path, fileKind: null);

            // Assert
            Assert.False(result.Exists);
        }
        public void GetItem_ReturnsNotFound_WhenFileDoesNotExistInNestedDirectory()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();
            var projectItem   = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml");

            // Act
            projectSystem.Add(projectItem);
            var actual = projectSystem.GetItem("/subDirectory/dir2/file2.cshtml");

            // Assert
            Assert.False(actual.Exists);
        }
コード例 #6
0
        public void GetItem_ReturnsItemAddedToRoot()
        {
            // Arrange
            var path          = "/root-file.cshtml";
            var projectSystem = new VirtualRazorProjectFileSystem();
            var projectItem   = new TestRazorProjectItem(path);

            // Act
            projectSystem.Add(projectItem);
            var actual = projectSystem.GetItem(path, fileKind: null);

            // Assert
            Assert.Same(projectItem, actual);
        }
コード例 #7
0
        public void EnumerateItems_ForNonExistentDirectory_ReturnsEmptySequence()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();

            projectSystem.Add(new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"));
            projectSystem.Add(new TestRazorProjectItem("/file2.cshtml"));

            // Act
            var result = projectSystem.EnumerateItems("/dir3");

            // Assert
            Assert.Empty(result);
        }
コード例 #8
0
        public void GetHierarchicalItems_Works()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();
            var viewImport1   = new TestRazorProjectItem("/_ViewImports.cshtml");
            var viewImport2   = new TestRazorProjectItem("/Views/Home/_ViewImports.cshtml");

            projectSystem.Add(viewImport1);
            projectSystem.Add(viewImport2);

            // Act
            var items = projectSystem.FindHierarchicalItems("/", "/Views/Home/Index.cshtml", "_ViewImports.cshtml");

            // Assert
            Assert.Collection(
                items,
                item => Assert.Same(viewImport2, item),
                item => Assert.False(item.Exists),
                item => Assert.Same(viewImport1, item));
        }
コード例 #9
0
        public void EnumerateItems_AtSubDirectory_ReturnsAllFilesUnderDirectoryHierarchy()
        {
            // Arrange
            var projectSystem = new VirtualRazorProjectFileSystem();
            var file1         = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml");
            var file2         = new TestRazorProjectItem("/file2.cshtml");
            var file3         = new TestRazorProjectItem("/dir3/file3.cshtml");
            var file4         = new TestRazorProjectItem("/subDirectory/file4.cshtml");

            projectSystem.Add(file1);
            projectSystem.Add(file2);
            projectSystem.Add(file3);
            projectSystem.Add(file4);

            // Act
            var result = projectSystem.EnumerateItems("/subDirectory");

            // Assert
            Assert.Equal(new[] { file4, file1 }, result);
        }