Beispiel #1
0
    public void GetShallowCloneByReflection_PropsAndFields()
    {
        var uri    = new Uri("http://www.stackoverflow.com");
        var source = new TestClassParent();

        source.SomePublicString   = "Pu";
        source.SomePrivateString  = "Pr";
        source.SomeInternalString = "I";
        source.SomeIntField       = 6;
        source.SomeList           = new List <Uri>()
        {
            uri
        };
        var dest = source.GetShallowCopyByReflection <TestClassChild>();

        Assert.AreEqual("Pu", dest.SomePublicString);
        Assert.AreEqual("Pr", dest.SomePrivateString);
        Assert.AreEqual("I", dest.SomeInternalString);
        Assert.AreEqual(6, dest.SomeIntField);
        Assert.AreSame(source.SomeList, dest.SomeList);
        Assert.AreSame(uri, dest.SomeList[0]);
    }
Beispiel #2
0
 public ClassWithParentDependency(TestClassParent dependency)
 {
     Dependency = dependency;
 }