예제 #1
0
        public void Visit_ThrowsIfThePassedInChunkIsNotASetBaseTypeChunk()
        {
            // Arrange
            var expected = "Argument must be an instance of " +
                           "'Microsoft.AspNet.Razor.Chunks.SetBaseTypeChunk'.";
            var merger = new SetBaseTypeChunkMerger("dynamic");

            // Act and Assert
            ExceptionAssert.ThrowsArgument(() => merger.VisitChunk(new LiteralChunk()), "chunk", expected);
        }
예제 #2
0
        public void Visit_ThrowsIfThePassedInChunkIsNotASetBaseTypeChunk()
        {
            // Arrange
            var expected = "Argument must be an instance of " +
                           "'Microsoft.AspNet.Razor.Generator.Compiler.SetBaseTypeChunk'.";
            var merger = new SetBaseTypeChunkMerger("dynamic");

            // Act and Assert
            ExceptionAssert.ThrowsArgument(() => merger.VisitChunk(new LiteralChunk()), "chunk", expected);
        }
예제 #3
0
        public void Merge_IgnoresSetBaseTypeChunksIfChunkTreeContainsOne()
        {
            // Arrange
            var merger = new SetBaseTypeChunkMerger("dynamic");
            var chunkTree = new ChunkTree();

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

            // Assert
            Assert.Empty(chunkTree.Chunks);
        }
예제 #4
0
        public void Visit_UpdatesTModelTokenToMatchModelType(string typeName, string expectedValue)
        {
            // Arrange
            var chunk = new SetBaseTypeChunk
            {
                TypeName = typeName,
            };
            var merger = new SetBaseTypeChunkMerger("Person");

            // Act
            merger.VisitChunk(chunk);

            // Assert
            Assert.Equal(expectedValue, chunk.TypeName);
        }
예제 #5
0
        public void Visit_UpdatesTModelTokenToMatchModelType(string typeName, string expectedValue)
        {
            // Arrange
            var chunk = new SetBaseTypeChunk
            {
                TypeName = typeName,
            };
            var merger = new SetBaseTypeChunkMerger("Person");

            // Act
            merger.VisitChunk(chunk);

            // Assert
            Assert.Equal(expectedValue, chunk.TypeName);
        }
예제 #6
0
        public void Merge_IgnoresSetBaseTypeChunksIfCodeTreeContainsOne()
        {
            // Arrange
            var merger   = new SetBaseTypeChunkMerger("dynamic");
            var codeTree = new CodeTree();

            // Act
            merger.VisitChunk(new SetBaseTypeChunk {
                TypeName = "MyBaseType1"
            });
            merger.Merge(codeTree, new SetBaseTypeChunk {
                TypeName = "MyBaseType2"
            });

            // Assert
            Assert.Empty(codeTree.Chunks);
        }
예제 #7
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);
        }