public void TryGet_BehaviorNotContained( ) { IBehaviorsContainer behaviors = new BehaviorsContainerBase( ); bool found = behaviors.TryGet(out TestBehavior behavior); Assert.IsFalse(found); Assert.IsNull(behavior); }
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); }
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); }
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); }
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); }