Ejemplo n.º 1
0
        public void TryGetRazorDocument_NonRazorFilePath_ReturnsFalse()
        {
            // Arrange
            var services  = new TestProjectSystemServices("C:\\Path\\Test.csproj");
            var host      = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager);
            var itemState = new Dictionary <string, string>()
            {
                [ItemReference.FullPathPropertyName] = "C:\\Path\\site.css",
            }.ToImmutableDictionary();

            // Act
            var result = host.TryGetRazorDocument(itemState, out var document);

            // Assert
            Assert.False(result);
            Assert.Null(document);
        }
        public void TryGetRazorDocument_NoFilePath_ReturnsFalse()
        {
            // Arrange
            var services = new TestProjectSystemServices("C:\\To\\Test.csproj");

            var host      = new TestFallbackRazorProjectHost(services, Workspace, Dispatcher, ProjectConfigurationFilePathStore, ProjectManager);
            var itemState = new Dictionary <string, string>()
            {
                [ItemReference.LinkPropertyName] = "Index.cshtml",
            }.ToImmutableDictionary();

            // Act
            var result = host.TryGetRazorDocument(itemState, out var document);

            // Assert
            Assert.False(result);
            Assert.Null(document);
        }
Ejemplo n.º 3
0
        public void TryGetRazorDocument_JustFilePath_ReturnsTrue()
        {
            // Arrange
            var expectedPath = "C:\\Path\\Index.cshtml";
            var services     = new TestProjectSystemServices("C:\\Path\\Test.csproj");
            var host         = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager);
            var itemState    = new Dictionary <string, string>()
            {
                [ItemReference.FullPathPropertyName] = expectedPath,
            }.ToImmutableDictionary();

            // Act
            var result = host.TryGetRazorDocument(itemState, out var document);

            // Assert
            Assert.True(result);
            Assert.Equal(expectedPath, document.FilePath);
            Assert.Equal(expectedPath, document.TargetPath);
        }
        public void TryGetRazorDocument_SetsLegacyFileKind()
        {
            // Arrange
            var expectedFullPath   = "C:\\Path\\From\\Index.cshtml";
            var expectedTargetPath = "C:\\Path\\To\\Index.cshtml";
            var services           = new TestProjectSystemServices("C:\\Path\\To\\Test.csproj");

            var host      = new TestFallbackRazorProjectHost(services, Workspace, RazorProjectChangePublisher, ProjectManager);
            var itemState = new Dictionary <string, string>()
            {
                [ItemReference.LinkPropertyName]     = "Index.cshtml",
                [ItemReference.FullPathPropertyName] = expectedFullPath,
            }.ToImmutableDictionary();

            // Act
            var result = host.TryGetRazorDocument(itemState, out var document);

            // Assert
            Assert.True(result);
            Assert.Equal(expectedFullPath, document.FilePath);
            Assert.Equal(expectedTargetPath, document.TargetPath);
            Assert.Equal(FileKinds.Legacy, document.FileKind);
        }