public void ShouldHandleRuntimeTypedComplexAndEnumerableElementMembers() { var source = new PublicTwoFields <object, IList <object> > { Value1 = new Product { ProductId = "kjdfskjnds" }, Value2 = new List <object> { new PublicProperty <string> { Value = "ikjhfeslkjdw" }, new PublicField <string> { Value = "ldkjkdhusdiuoji" } } }; var result = source.DeepClone(); result.Value1.ShouldBeOfType <Product>(); ((Product)result.Value1).ProductId.ShouldBe("kjdfskjnds"); result.Value2.Count.ShouldBe(2); result.Value2.First().ShouldBeOfType <PublicProperty <string> >(); ((PublicProperty <string>)result.Value2.First()).Value.ShouldBe("ikjhfeslkjdw"); result.Value2.Second().ShouldBeOfType <PublicField <string> >(); ((PublicField <string>)result.Value2.Second()).Value.ShouldBe("ldkjkdhusdiuoji"); }
public void ShouldCloneSimpleTypeValuesInAnObjectDictionary() { var source = new PublicTwoFields <int, Dictionary <string, object> > { Value1 = 6372, Value2 = new Dictionary <string, object> { ["QueryName"] = "References", ["IsDefault"] = false, ["QueryId"] = 155, ["WorkspaceTypeId"] = 1, ["IsUserDefined"] = true, ["QueryTypeId"] = 2, ["Test"] = default(int?) } }; var result = source.DeepClone(); result.Value1.ShouldBe(6372); result.Value2.ShouldNotBeNull(); result.Value2.ShouldNotBeSameAs(source.Value2); result.Value2.Count.ShouldBe(source.Value2.Count); result.Value2.ShouldContainKeyAndValue("QueryName", "References"); result.Value2.ShouldContainKeyAndValue("IsDefault", false); result.Value2.ShouldContainKeyAndValue("QueryId", 155); result.Value2.ShouldContainKeyAndValue("WorkspaceTypeId", 1); result.Value2.ShouldContainKeyAndValue("IsUserDefined", true); result.Value2.ShouldContainKeyAndValue("QueryTypeId", 2); result.Value2.ShouldContainKeyAndValue("Test", null); }