コード例 #1
0
        public void Merge_PicksLastBaseTypeChunkFromChunkTree()
        {
            // Arrange
            var merger          = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree       = new ChunkTree();
            var inheritedChunks = new Chunk[]
            {
                new SetBaseTypeChunk {
                    TypeName = "MyBase2"
                },
                new LiteralChunk(),
                new SetBaseTypeChunk {
                    TypeName = "MyBase1"
                },
            };

            // Act
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            var chunk            = Assert.Single(chunkTree.Chunks);
            var setBaseTypeChunk = Assert.IsType <SetBaseTypeChunk>(chunk);

            Assert.Equal("MyBase1", setBaseTypeChunk.TypeName);
        }
コード例 #2
0
        public void Merge_IgnoresSetBaseTypeChunksIfChunkTreeContainsOne()
        {
            // Arrange
            var merger = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree = new ChunkTree();
            var inheritedChunks = new[]
            {
                 new SetBaseTypeChunk { TypeName = "MyBaseType2" }
            };

            // Act
            merger.VisitChunk(new SetBaseTypeChunk { TypeName = "MyBaseType1" });
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            Assert.Empty(chunkTree.Children);
        }
コード例 #3
0
        public void Merge_SetsBaseTypeIfItHasNotBeenSetInChunkTree()
        {
            // Arrange
            var expected = "MyApp.Razor.MyBaseType";
            var merger = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree = new ChunkTree();
            var inheritedChunks = new[]
            {
                new SetBaseTypeChunk { TypeName = expected }
            };

            // Act
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            var chunk = Assert.Single(chunkTree.Children);
            var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
            Assert.Equal(expected, setBaseTypeChunk.TypeName);
        }
コード例 #4
0
        public void Merge_PicksLastBaseTypeChunkFromChunkTree()
        {
            // Arrange
            var merger = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree = new ChunkTree();
            var inheritedChunks = new Chunk[]
            {
                 new SetBaseTypeChunk { TypeName = "MyBase2" },
                 new LiteralChunk(),
                 new SetBaseTypeChunk { TypeName = "MyBase1" },
            };

            // Act
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            var chunk = Assert.Single(chunkTree.Children);
            var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
            Assert.Equal("MyBase1", setBaseTypeChunk.TypeName);
        }
コード例 #5
0
        public void Merge_IgnoresSetBaseTypeChunksIfChunkTreeContainsOne()
        {
            // Arrange
            var merger          = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree       = new ChunkTree();
            var inheritedChunks = new[]
            {
                new SetBaseTypeChunk {
                    TypeName = "MyBaseType2"
                }
            };

            // Act
            merger.VisitChunk(new SetBaseTypeChunk {
                TypeName = "MyBaseType1"
            });
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            Assert.Empty(chunkTree.Chunks);
        }
コード例 #6
0
        public void Merge_SetsBaseTypeIfItHasNotBeenSetInChunkTree()
        {
            // Arrange
            var expected        = "MyApp.Razor.MyBaseType";
            var merger          = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree       = new ChunkTree();
            var inheritedChunks = new[]
            {
                new SetBaseTypeChunk {
                    TypeName = expected
                }
            };

            // Act
            merger.MergeInheritedChunks(chunkTree, inheritedChunks);

            // Assert
            var chunk            = Assert.Single(chunkTree.Chunks);
            var setBaseTypeChunk = Assert.IsType <SetBaseTypeChunk>(chunk);

            Assert.Equal(expected, setBaseTypeChunk.TypeName);
        }