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); }
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); }
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); }
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); }
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); }
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); }