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