Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }