public void TestCast() { SimpleAdaptable adaptable = null; // test null check Assert.Throws <AdaptationException>(delegate() { adaptable.Cast(typeof(object)); }); Assert.Throws <AdaptationException>(delegate() { adaptable.Cast(typeof(object)); }); // test successful adaptation adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast(typeof(IAdaptable))); Assert.False(adaptable.AsCalled); adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast(typeof(IAdaptable))); Assert.False(adaptable.AsCalled); }
public void TestCastGeneric() { SimpleAdaptable adaptable = null; // test null check Assert.Throws <AdaptationException>(delegate() { Adapters.Cast <object>(adaptable); }); Assert.Throws <AdaptationException>(delegate() { adaptable.Cast <object>(); }); // test successful adaptation adaptable = new SimpleAdaptable(); Assert.NotNull(Adapters.Cast <IAdaptable>(adaptable)); Assert.False(adaptable.AsCalled); adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast <IAdaptable>()); Assert.False(adaptable.AsCalled); }
public void TestCast() { SimpleAdaptable adaptable = null; // test null check Assert.Throws<AdaptationException>(delegate() { Adapters.Cast(adaptable, typeof(object)); }); Assert.Throws<AdaptationException>(delegate() { adaptable.Cast(typeof(object)); }); // test successful adaptation adaptable = new SimpleAdaptable(); Assert.NotNull(Adapters.Cast(adaptable, typeof(IAdaptable))); Assert.False(adaptable.AsCalled); adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast(typeof(IAdaptable))); Assert.False(adaptable.AsCalled); }
public void TestCastGeneric() { SimpleAdaptable adaptable = null; // test null check Assert.Throws<AdaptationException>(delegate() { adaptable.Cast<object>(); }); Assert.Throws<AdaptationException>(delegate() { adaptable.Cast<object>(); }); // test successful adaptation adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast<IAdaptable>()); Assert.False(adaptable.AsCalled); adaptable = new SimpleAdaptable(); Assert.NotNull(adaptable.Cast<IAdaptable>()); Assert.False(adaptable.AsCalled); }