예제 #1
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedDuringMerge()
        {
            // Arrange
            var merger   = new UsingChunkMerger();
            var codeTree = new CodeTree();

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

            // Assert
            Assert.Equal(2, codeTree.Chunks.Count);
            var chunk = Assert.IsType <UsingChunk>(codeTree.Chunks[0]);

            Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
            chunk = Assert.IsType <UsingChunk>(codeTree.Chunks[1]);
            Assert.Equal("Microsoft.AspNet.Mvc.Razor", chunk.Namespace);
        }
예제 #2
0
        public void Merge_IgnoresNamespacesThatHaveBeenVisitedDuringMerge()
        {
            // Arrange
            var merger = new UsingChunkMerger();
            var codeTree = new CodeTree();

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

            // Assert
            Assert.Equal(2, codeTree.Chunks.Count);
            var chunk = Assert.IsType<UsingChunk>(codeTree.Chunks[0]);
            Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
            chunk = Assert.IsType<UsingChunk>(codeTree.Chunks[1]);
            Assert.Equal("Microsoft.AspNet.Mvc.Razor", chunk.Namespace);
        }
예제 #3
0
        public void Merge_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.Merge(new CodeTree(), new LiteralChunk()), "chunk", expected);
        }
예제 #4
0
        public void Merge_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.Merge(new CodeTree(), new LiteralChunk()), "chunk", expected);
        }
예제 #5
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);
        }
예제 #6
0
        public void Merge_MacthesNamespacesInCaseSensitiveManner()
        {
            // Arrange
            var merger   = new UsingChunkMerger();
            var codeTree = new CodeTree();

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

            // Assert
            Assert.Equal(2, codeTree.Chunks.Count);
            var chunk = Assert.IsType <UsingChunk>(codeTree.Chunks[0]);

            Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
            chunk = Assert.IsType <UsingChunk>(codeTree.Chunks[1]);
            Assert.Equal("Microsoft.AspNet.mvc", chunk.Namespace);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
0
        public void Merge_MacthesNamespacesInCaseSensitiveManner()
        {
            // Arrange
            var merger = new UsingChunkMerger();
            var codeTree = new CodeTree();

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

            // Assert
            Assert.Equal(2, codeTree.Chunks.Count);
            var chunk = Assert.IsType<UsingChunk>(codeTree.Chunks[0]);
            Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
            chunk = Assert.IsType<UsingChunk>(codeTree.Chunks[1]);
            Assert.Equal("Microsoft.AspNet.mvc", chunk.Namespace);
        }