public async void Polymorphism_For_Override_Method() { Duck duck = new ExecitedDuck(); IDuck target = duck.As <IDuck>(); Assert.Equal(await duck.WalkAsync(), await target.WalkAsync()); Assert.Same(duck, target.GetSource <Duck>()); Assert.Same(duck, target.GetSource <ExecitedDuck>()); }
public void Should_Use_Original_Object() { Duck source = new Duck(); IDuck target = source.As <IDuck>(); Assert.Same(source, target); Assert.Same(source, target.GetSource <Duck>()); Assert.Throws <ArgumentException>(() => target.GetSource <ExecitedDuck>()); }
public void Hide_Base_Using_New() { ExecitedDuck source = new ExecitedDuck(); IDuck target = source.As <IDuck>(); Assert.Equal(source.Quack(), target.Quack()); Assert.Same(source, target.GetSource <Duck>()); Assert.Same(source, target.GetSource <ExecitedDuck>()); }
public void Primitive_Type_As_Unrelated_Interface() { int source = 1; IDuck target = source.As <IDuck>(); Assert.NotNull(target); Assert.Equal(source, target.GetSource <int>()); Assert.Throws <InvalidCastException>(() => target.GetSource <long>()); }
public async Task Override_Virtual_Method() { ExecitedDuck source = new ExecitedDuck(); IDuck target = source.As <IDuck>(); Assert.Equal(await source.WalkAsync(), await target.WalkAsync()); Assert.Same(source, target.GetSource <ExecitedDuck>()); }
public void Null_Can_Be_Goosed() { Duck source = null; IDuck target = source.As <IDuck>(); Assert.NotNull(target); Assert.Null(target.GetSource <Duck>()); }
public void Get_Source_Reference_Check() { Assert.Same(_source, _target.GetSource <Duck>()); }