示例#1
0
        public void TryGet_BehaviorNotContained( )
        {
            IBehaviorsContainer behaviors = new BehaviorsContainerBase( );
            bool found = behaviors.TryGet(out TestBehavior behavior);

            Assert.IsFalse(found);
            Assert.IsNull(behavior);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }