public void UnsafeCast_DelegateOfSameTypeSignature() { Predicate <string> predicate = x => x.Length % 2 == 0; Func <string, bool> func = UnsafeCast <Predicate <string>, Func <string, bool> > .With(predicate); Assert.IsTrue(func("Hello!")); }
public void UnsafeCast_ClassToClassOfSameStructure() { A source = new A { Foo = 42 }; C result = UnsafeCast <A, C> .With(source); Assert.AreEqual(42, result.Bar); }
public void UnsafeCast_ClassToClassOfSupersetStructure() { A source = new A { Foo = 42 }; B result = UnsafeCast <A, B> .With(source); Assert.AreEqual(42, result.Foo); Assert.AreEqual(0, result.Bar); }