예제 #1
0
        public void TryComputeNamespace_IncompleteDirective_UsesEmptyNamespace()
        {
            // Arrange
            var source  = "c:\\foo\\bar\\bleh.cshtml";
            var imports = "c:\\foo\\baz\\bleh.cshtml";
            var node    = new DirectiveIntermediateNode()
            {
                Directive = NamespaceDirective.Directive,
                Source    = new SourceSpan(imports, 0, 0, 0, 0),
            };

            // Act
            var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace);

            // Assert
            Assert.False(computed);
            Assert.Equal(string.Empty, @namespace);
        }
예제 #2
0
        public void TryComputeNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected)
        {
            // Arrange
            var node = new DirectiveIntermediateNode()
            {
                Directive = NamespaceDirective.Directive,
                Source    = new SourceSpan(imports, 0, 0, 0, 0),
            };

            node.Children.Add(new DirectiveTokenIntermediateNode()
            {
                Content = "Base"
            });

            // Act
            var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace);

            // Assert
            Assert.True(computed);
            Assert.Equal(expected, @namespace);
        }
예제 #3
0
        public void TryComputeNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports)
        {
            // Arrange
            var node = new DirectiveIntermediateNode()
            {
                Directive = NamespaceDirective.Directive,
                Source    = new SourceSpan(imports, 0, 0, 0, 0),
            };

            node.Children.Add(new DirectiveTokenIntermediateNode()
            {
                Content = "Base"
            });

            // Act
            var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace);

            // Assert
            Assert.False(computed);
            Assert.Equal("Base", @namespace);
        }