Ejemplo n.º 1
0
        public void TestAsAll()
        {
            SimpleAdapter test;

            test = new SimpleAdapter();
            Utilities.TestSequenceEqual(test.GetDecorators(typeof(ISimpleInterface)), test);
            Assert.True(test.AdaptCalled);

            test = new SimpleAdapter();
            CollectionAssert.IsEmpty(test.GetDecorators(typeof(TestAdapter)));
            Assert.True(test.AdaptCalled);

            SimpleAdapter adaptee = new SimpleAdapter();

            test = new SimpleAdapter(adaptee); // wrap itself
            Utilities.TestSequenceEqual(test.GetDecorators(typeof(SimpleAdapter)), test, adaptee);
            Assert.True(test.AdaptCalled);

            // If the adaptee can be adapted to the adapter, we want to make sure that
            //  GetDecorators() doesn't return two identical decorators. http://tracker.ship.scea.com/jira/browse/WWSATF-1483
            var decoratableAdaptee = new DecoratableAdaptee();
            var decoratingAdapter  = new DecoratingAdapter(decoratableAdaptee);
            var adapters           = new List <DecoratingAdapter>(decoratingAdapter.AsAll <DecoratingAdapter>());

            Utilities.TestSequenceContainSameItems(adapters, decoratingAdapter);
        }
Ejemplo n.º 2
0
        public void TestAsAll()
        {
            SimpleAdapter test;

            test = new SimpleAdapter();
            Utilities.TestSequenceEqual(test.GetDecorators(typeof(ISimpleInterface)), test);
            Assert.True(test.AdaptCalled);

            test = new SimpleAdapter();
            CollectionAssert.IsEmpty(test.GetDecorators(typeof(TestAdapter)));
            Assert.True(test.AdaptCalled);

            SimpleAdapter adaptee = new SimpleAdapter();
            test = new SimpleAdapter(adaptee); // wrap itself
            Utilities.TestSequenceEqual(test.GetDecorators(typeof(SimpleAdapter)), test, adaptee);
            Assert.True(test.AdaptCalled);

            // If the adaptee can be adapted to the adapter, we want to make sure that
            //  GetDecorators() doesn't return two identical decorators. http://tracker.ship.scea.com/jira/browse/WWSATF-1483
            var decoratableAdaptee = new DecoratableAdaptee();
            var decoratingAdapter = new DecoratingAdapter(decoratableAdaptee);
            var adapters = new List<DecoratingAdapter>(decoratingAdapter.AsAll<DecoratingAdapter>());
            Utilities.TestSequenceContainSameItems(adapters, decoratingAdapter);
        }
Ejemplo n.º 3
0
 public DecoratingAdapter(DecoratableAdaptee adaptee)
     : base(adaptee)
 {
     adaptee.Decorator = this;
 }
Ejemplo n.º 4
0
 public DecoratingAdapter(DecoratableAdaptee adaptee)
     : base(adaptee)
 {
     adaptee.Decorator = this;
 }