Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }