Ejemplo n.º 1
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.AspNet.Mvc"
            });
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            var chunk      = Assert.Single(chunkTree.Chunks);
            var usingChunk = Assert.IsType <UsingChunk>(chunk);

            Assert.Equal(expected, usingChunk.Namespace);
        }
Ejemplo n.º 2
0
        public void Visit_ThrowsIfThePassedInChunkIsNotAUsingChunk()
        {
            // Arrange
            var expected = "Argument must be an instance of 'Microsoft.AspNet.Razor.Generator.Compiler.UsingChunk'.";
            var merger = new UsingChunkMerger();

            // Act and Assert
            ExceptionAssert.ThrowsArgument(() => merger.VisitChunk(new LiteralChunk()), "chunk", expected);
        }
Ejemplo n.º 3
0
        public void Visit_ThrowsIfThePassedInChunkIsNotAUsingChunk()
        {
            // Arrange
            var expected = "Argument must be an instance of 'Microsoft.AspNet.Razor.Generator.Compiler.UsingChunk'.";
            var merger   = new UsingChunkMerger();

            // Act and Assert
            ExceptionAssert.ThrowsArgument(() => merger.VisitChunk(new LiteralChunk()), "chunk", expected);
        }
Ejemplo n.º 4
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedInCodeTree()
        {
            // Arrange
            var merger = new UsingChunkMerger();
            var codeTree = new CodeTree();

            // Act
            merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNet.Mvc" });
            merger.Merge(codeTree, new UsingChunk { Namespace = "Microsoft.AspNet.Mvc" });

            // Assert
            Assert.Empty(codeTree.Chunks);
        }
Ejemplo n.º 5
0
        public void Merge_AddsNamespacesThatHaveNotBeenVisitedInCodeTree()
        {
            // Arrange
            var expected = "MyApp.Models";
            var merger = new UsingChunkMerger();
            var codeTree = new CodeTree();

            // Act
            merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNet.Mvc" });
            merger.Merge(codeTree, new UsingChunk { Namespace = expected });

            // Assert
            var chunk = Assert.Single(codeTree.Chunks);
            var usingChunk = Assert.IsType<UsingChunk>(chunk);
            Assert.Equal(expected, usingChunk.Namespace);
        }
Ejemplo n.º 6
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedInCodeTree()
        {
            // Arrange
            var merger   = new UsingChunkMerger();
            var codeTree = new CodeTree();

            // Act
            merger.VisitChunk(new UsingChunk {
                Namespace = "Microsoft.AspNet.Mvc"
            });
            merger.Merge(codeTree, new UsingChunk {
                Namespace = "Microsoft.AspNet.Mvc"
            });

            // Assert
            Assert.Empty(codeTree.Chunks);
        }
Ejemplo n.º 7
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedInChunkTree()
        {
            // Arrange
            var merger = new UsingChunkMerger();
            var chunkTree = new ChunkTree();
            var inheritedChunks = new Chunk[]
            {
                new UsingChunk { Namespace = "Microsoft.AspNet.Mvc" },
                new InjectChunk("Foo", "Bar")
            };

            // Act
            merger.VisitChunk(new UsingChunk { Namespace = "Microsoft.AspNet.Mvc" });
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            Assert.Empty(chunkTree.Children);
        }
Ejemplo n.º 8
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedInChunkTree()
        {
            // Arrange
            var merger          = new UsingChunkMerger();
            var chunkTree       = new ChunkTree();
            var inheritedChunks = new Chunk[]
            {
                new UsingChunk {
                    Namespace = "Microsoft.AspNet.Mvc"
                },
                new InjectChunk("Foo", "Bar")
            };

            // Act
            merger.VisitChunk(new UsingChunk {
                Namespace = "Microsoft.AspNet.Mvc"
            });
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            Assert.Empty(chunkTree.Chunks);
        }