Ejemplo n.º 1
0
        public void TryGet_BehaviorNotContained( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );
            bool found = behaviors.TryGet(out TestBehavior behavior);

            Assert.IsFalse(found);
            Assert.IsNull(behavior);
        }
Ejemplo n.º 2
0
        public void TryGet_BehaviorContained( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );

            behaviors.Set(new TestBehavior( ));
            bool found = behaviors.TryGet(out TestBehavior behavior);

            Assert.IsTrue(found);
            Assert.IsNotNull(behavior);
        }
Ejemplo n.º 3
0
        public void Get_BehaviorReplaced( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );
            TestBehavior        behavior1 = new TestBehavior( );
            TestBehavior        behavior2 = new TestBehavior( );

            behaviors.Set(behavior1);
            behaviors.Set(behavior2);
            TestBehavior behavior = behaviors.Get <TestBehavior>( );

            Assert.IsNotNull(behavior);
            Assert.AreSame(behavior2, behavior);
        }
Ejemplo n.º 4
0
        public void Get_BehaviorNotContained( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );
            Exception           exc       = null;
            TestBehavior        behavior  = null;

            try {
                behavior = behaviors.Get <TestBehavior>( );
            } catch (Exception exc2) {
                exc = exc2;
            }

            Assert.IsNull(behavior);
            Assert.IsNotNull(exc);
            Assert.IsInstanceOf <ArgumentException>(exc);
        }
Ejemplo n.º 5
0
        public void Get_BehaviorContained( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );

            behaviors.Set(new TestBehavior( ));
            Exception    exc      = null;
            TestBehavior behavior = null;

            try {
                behavior = behaviors.Get <TestBehavior>( );
            } catch (Exception exc2) {
                exc = exc2;
            }

            Assert.IsNotNull(behavior);
            Assert.IsNull(exc);
        }