public void Merge_MatchesNamespacesInCaseSensitiveManner() { // Arrange var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new[] { new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.mvc" } }; // Act merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert Assert.Equal(2, chunkTree.Children.Count); var chunk = Assert.IsType <UsingChunk>(chunkTree.Children[0]); Assert.Equal("Microsoft.AspNetCore.Mvc", chunk.Namespace); chunk = Assert.IsType <UsingChunk>(chunkTree.Children[1]); Assert.Equal("Microsoft.AspNetCore.mvc", chunk.Namespace); }
public void Merge_AddsNamespacesThatHaveNotBeenVisitedInChunkTree() { // Arrange var expected = "MyApp.Models"; var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new Chunk[] { new UsingChunk { Namespace = expected }, }; // Act merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }); merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert var chunk = Assert.Single(chunkTree.Children); var usingChunk = Assert.IsType <UsingChunk>(chunk); Assert.Equal(expected, usingChunk.Namespace); }
public void Merge_DoesNotAddMoreThanOneInstanceOfTheSameInheritedNamespace() { // Arrange var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new Chunk[] { new LiteralChunk(), new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc.Razor" } }; // Act merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert Assert.Equal(2, chunkTree.Children.Count); var chunk = Assert.IsType <UsingChunk>(chunkTree.Children[0]); Assert.Equal("Microsoft.AspNetCore.Mvc", chunk.Namespace); chunk = Assert.IsType <UsingChunk>(chunkTree.Children[1]); Assert.Equal("Microsoft.AspNetCore.Mvc.Razor", chunk.Namespace); }
public void Merge_IgnoresNamespacesThatHaveBeenVisitedInChunkTree() { // Arrange var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new Chunk[] { new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new InjectChunk("Foo", "Bar") }; // Act merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }); merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert Assert.Empty(chunkTree.Children); }
public void Merge_AddsNamespacesThatHaveNotBeenVisitedInChunkTree() { // Arrange var expected = "MyApp.Models"; var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new Chunk[] { new UsingChunk { Namespace = expected }, }; // Act merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }); merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert var chunk = Assert.Single(chunkTree.Children); var usingChunk = Assert.IsType<UsingChunk>(chunk); Assert.Equal(expected, usingChunk.Namespace); }
public void Merge_DoesNotAddMoreThanOneInstanceOfTheSameInheritedNamespace() { // Arrange var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new Chunk[] { new LiteralChunk(), new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc.Razor" } }; // Act merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert Assert.Equal(2, chunkTree.Children.Count); var chunk = Assert.IsType<UsingChunk>(chunkTree.Children[0]); Assert.Equal("Microsoft.AspNetCore.Mvc", chunk.Namespace); chunk = Assert.IsType<UsingChunk>(chunkTree.Children[1]); Assert.Equal("Microsoft.AspNetCore.Mvc.Razor", chunk.Namespace); }
public void Merge_MatchesNamespacesInCaseSensitiveManner() { // Arrange var merger = new UsingChunkMerger(); var chunkTree = new ChunkTree(); var inheritedChunks = new[] { new UsingChunk { Namespace = "Microsoft.AspNetCore.Mvc" }, new UsingChunk { Namespace = "Microsoft.AspNetCore.mvc" } }; // Act merger.MergeInheritedChunks(chunkTree, inheritedChunks); // Assert Assert.Equal(2, chunkTree.Children.Count); var chunk = Assert.IsType<UsingChunk>(chunkTree.Children[0]); Assert.Equal("Microsoft.AspNetCore.Mvc", chunk.Namespace); chunk = Assert.IsType<UsingChunk>(chunkTree.Children[1]); Assert.Equal("Microsoft.AspNetCore.mvc", chunk.Namespace); }