예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }