public void GetNamespace_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 @namespace = NamespaceDirective.GetNamespace(source, node); // Assert Assert.Equal(string.Empty, @namespace); }
public void GetNamespace_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 @namespace = NamespaceDirective.GetNamespace(source, node); // Assert Assert.Equal(expected, @namespace); }
public void GetNamespace_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 @namespace = NamespaceDirective.GetNamespace(source, node); // Assert Assert.Equal("Base", @namespace); }
public void GetNamespace_EmptyDirective_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), }; node.Children.Add(new DirectiveTokenIntermediateNode() { Content = string.Empty }); // Act var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert Assert.Equal(string.Empty, @namespace); }