예제 #1
0
        public void TestAs_CastAndGetAdapterFail()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.Null(Adapters.As(adaptable, typeof(TestAdapters)));
            Assert.True(adaptable.AsCalled);
        }
예제 #2
0
        public void TestAs_GetAdapterIfCastFails()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.NotNull(Adapters.As(adaptable, typeof(string)));
            Assert.True(adaptable.AsCalled);
        }
예제 #3
0
        public void TestAsGeneric_CastFirst()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.AreSame(Adapters.As <IAdaptable>(adaptable), adaptable);
            Assert.False(adaptable.AsCalled);
        }
예제 #4
0
        public void TestAsGeneric_GetAdapterIfCastFails()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.NotNull(Adapters.As <string>(adaptable));
            Assert.True(adaptable.AsCalled);
        }
예제 #5
0
        public void TestAsGeneric_CastAndGetAdapterFail()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.Null(Adapters.As <TestAdapters>(adaptable));
            Assert.True(adaptable.AsCalled);
        }
예제 #6
0
        public void TestAs_CastFirst()
        {
            SimpleAdaptable adaptable = new SimpleAdaptable();

            Assert.AreSame(Adapters.As(adaptable, typeof(IAdaptable)), adaptable);
            Assert.False(adaptable.AsCalled);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
        public void TestIsGeneric()
        {
            SimpleAdaptable adaptable = null;

            // test null check
            Assert.False(Adapters.Is <object>(adaptable));
            Assert.False(adaptable.Is <object>());

            // test successful adaptation
            adaptable = new SimpleAdaptable();
            Assert.True(Adapters.Is <IAdaptable>(adaptable));
            adaptable = new SimpleAdaptable();
            Assert.NotNull(adaptable.Is <IAdaptable>());

            // test failed adaptation
            adaptable = new SimpleAdaptable();
            Assert.False(Adapters.Is <TestAdapters>(adaptable));
            adaptable = new SimpleAdaptable();
            Assert.False(adaptable.Is <TestAdapters>());
        }
예제 #10
0
        public void TestIs()
        {
            SimpleAdaptable adaptable = null;

            // test null check
            Assert.False(Adapters.Is(adaptable, typeof(object)));
            Assert.False(adaptable.Is(typeof(object)));

            // test successful adaptation
            adaptable = new SimpleAdaptable();
            Assert.True(Adapters.Is(adaptable, typeof(IAdaptable)));
            adaptable = new SimpleAdaptable();
            Assert.NotNull(adaptable.Is(typeof(IAdaptable)));

            // test failed adaptation
            adaptable = new SimpleAdaptable();
            Assert.False(Adapters.Is(adaptable, typeof(TestAdapters)));
            adaptable = new SimpleAdaptable();
            Assert.False(adaptable.Is(typeof(TestAdapters)));
        }
예제 #11
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
        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);
        }
예제 #12
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
        public void TestIs()
        {
            SimpleAdaptable adaptable = null;

            // test null check
            Assert.False(Adapters.Is(adaptable, typeof(object)));
            Assert.False(adaptable.Is(typeof(object)));

            // test successful adaptation
            adaptable = new SimpleAdaptable();
            Assert.True(Adapters.Is(adaptable, typeof(IAdaptable)));
            adaptable = new SimpleAdaptable();
            Assert.NotNull(adaptable.Is(typeof(IAdaptable)));

            // test failed adaptation
            adaptable = new SimpleAdaptable();
            Assert.False(Adapters.Is(adaptable, typeof(TestAdapters)));
            adaptable = new SimpleAdaptable();
            Assert.False(adaptable.Is(typeof(TestAdapters)));
        }
예제 #13
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
        public void TestIsGeneric()
        {
            SimpleAdaptable adaptable = null;

            // test null check
            Assert.False(Adapters.Is<object>(adaptable));
            Assert.False(adaptable.Is<object>());

            // test successful adaptation
            adaptable = new SimpleAdaptable();
            Assert.True(Adapters.Is<IAdaptable>(adaptable));
            adaptable = new SimpleAdaptable();
            Assert.NotNull(adaptable.Is<IAdaptable>());

            // test failed adaptation
            adaptable = new SimpleAdaptable();
            Assert.False(Adapters.Is<TestAdapters>(adaptable));
            adaptable = new SimpleAdaptable();
            Assert.False(adaptable.Is<TestAdapters>());
        }
예제 #14
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAs_CastFirst()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.AreSame(Adapters.As(adaptable, typeof(IAdaptable)), adaptable);
     Assert.False(adaptable.AsCalled);
 }
예제 #15
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAs_GetAdapterIfCastFails()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.NotNull(Adapters.As(adaptable, typeof(string)));
     Assert.True(adaptable.AsCalled);
 }
예제 #16
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAs_CastAndGetAdapterFail()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.Null(Adapters.As(adaptable, typeof(TestAdapters)));
     Assert.True(adaptable.AsCalled);
 }
예제 #17
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAsGeneric_CastFirst()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.AreSame(Adapters.As<IAdaptable>(adaptable), adaptable);
     Assert.False(adaptable.AsCalled);
 }
예제 #18
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);
        }
예제 #19
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAsGeneric_CastAndGetAdapterFail()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.Null(Adapters.As<TestAdapters>(adaptable));
     Assert.True(adaptable.AsCalled);
 }
예제 #20
0
파일: TestAdapters.cs 프로젝트: Joxx0r/ATF
 public void TestAsGeneric_GetAdapterIfCastFails()
 {
     SimpleAdaptable adaptable = new SimpleAdaptable();
     Assert.NotNull(Adapters.As<string>(adaptable));
     Assert.True(adaptable.AsCalled);
 }