public void ExampleInterfaceContainerWorks() { ExampleInterfaceContainer c = new ExampleInterfaceContainer() { ExampleByInterface = GetExample(2), }; var c2 = c.CloneLazinatorTyped(); ExampleEqual((Example)c.ExampleByInterface, (Example)c2.ExampleByInterface).Should().BeTrue(); }
public void IncludeChildrenModeWorks_UnaccessedProperties() { // same as previous test, except that put everything in a container, and we make sure that the Example object // itself is unaccessed at the beginning of the clone. Thus, the question is whether we'll exclude children // appropriately when those children were originally contained within an unaccessed property. We'll repeatedly // clone the container (to make sure all properties are unaccessed) and then clone again into a different // variable (to test the effect of IncludeChildrenMode). ExampleInterfaceContainer container = new ExampleInterfaceContainer(); container.ExampleByInterface = GetHierarchy(1, 1, 1, 1, 1); container.ExampleByInterface.IncludableChild = GetExampleChild(1); container.ExampleByInterface.ExcludableChild = GetExampleChild(1); container = container.CloneLazinatorTyped(); var result = container.CloneLazinatorTyped(IncludeChildrenMode.ExcludeAllChildren); result.ExampleByInterface.Should().BeNull(); container = container.CloneLazinatorTyped(); result = container.CloneLazinatorTyped(IncludeChildrenMode.IncludeAllChildren); result.ExampleByInterface.IncludableChild.Should().NotBeNull(); result.ExampleByInterface.ExcludableChild.Should().NotBeNull(); result.ExampleByInterface.MyChild1.Should().NotBeNull(); container = container.CloneLazinatorTyped(); result = container.CloneLazinatorTyped(IncludeChildrenMode.ExcludeOnlyExcludableChildren); result.ExampleByInterface.IncludableChild.Should().NotBeNull(); result.ExampleByInterface.ExcludableChild.Should().BeNull(); result.ExampleByInterface.MyChild1.Should().NotBeNull(); container = container.CloneLazinatorTyped(); result = container.CloneLazinatorTyped(IncludeChildrenMode.IncludeOnlyIncludableChildren); result.ExampleByInterface.Should().NotBeNull(); // because ExampleByInterface is defined as an includable child result.ExampleByInterface.IncludableChild.Should().NotBeNull(); result.ExampleByInterface.ExcludableChild.Should().BeNull(); result.ExampleByInterface.MyChild1.Should().BeNull(); }