コード例 #1
0
        public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk()
        {
            // Arrange
            var imports        = new List <RazorProjectItem>();
            var projectItem    = new TestRazorProjectItem("/Contact/Index.cshtml");
            var testFileSystem = new TestRazorProjectFileSystem(new[]
            {
                new TestRazorProjectItem("/Index.cshtml"),
                new TestRazorProjectItem("/_ViewImports.cshtml"),
                new TestRazorProjectItem("/Contact/_ViewImports.cshtml"),
                projectItem,
            });
            var mvcImportFeature = new MvcImportProjectFeature()
            {
                ProjectEngine = Mock.Of <RazorProjectEngine>(projectEngine => projectEngine.FileSystem == testFileSystem)
            };

            // Act
            mvcImportFeature.AddHierarchicalImports(projectItem, imports);

            // Assert
            Assert.Collection(imports,
                              import => Assert.Equal("/_ViewImports.cshtml", import.FilePath),
                              import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath));
        }
コード例 #2
0
        public void AddDefaultDirectivesImport_AddsSingleDynamicImport()
        {
            // Arrange
            var imports = new List <RazorProjectItem>();

            // Act
            MvcImportProjectFeature.AddDefaultDirectivesImport(imports);

            // Assert
            var import = Assert.Single(imports);

            Assert.Null(import.FilePath);
        }