Skip to content

Commit b3b866f

Browse files
committed
add test case for interface fields
1 parent 1702e58 commit b3b866f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

FastCloner.Tests/SpecialCaseTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,4 +1892,42 @@ public T Value
18921892

18931893
public LazyRef(Func<T> initializer) => _initializer = initializer;
18941894
}
1895+
1896+
[Test]
1897+
public void CanCopyInterfaceField()
1898+
{
1899+
MyObject o = new MyObject();
1900+
1901+
MyIClass original = new MyIClass
1902+
{
1903+
Field1 = o,
1904+
Field2 = o
1905+
};
1906+
1907+
MyIClass result = original.DeepClone();
1908+
1909+
Assert.Multiple(() =>
1910+
{
1911+
Assert.That(original.Field1, Is.SameAs(original.Field2), "Original objects should be same");
1912+
Assert.That(result.Field1, Is.SameAs(result.Field2), "Cloned objects should be same");
1913+
});
1914+
}
1915+
1916+
public class MyIClass
1917+
{
1918+
public IMyInterface1 Field1;
1919+
public IMyInterface2 Field2;
1920+
}
1921+
1922+
public interface IMyInterface1
1923+
{
1924+
}
1925+
1926+
public interface IMyInterface2
1927+
{
1928+
}
1929+
1930+
public class MyObject : IMyInterface1, IMyInterface2
1931+
{
1932+
}
18951933
}

0 commit comments

Comments
 (0)