Example #1
0
        public void WhenAddingStuntBehaviorToObject_ThenCanAddInterface()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior(new TestStuntBehavior());

            Assert.Single(((IStunt)stunt).Behaviors);
        }
Example #2
0
        public void WhenAddingStuntBehavior_ThenCanAddLambda()
        {
            var stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);

            Assert.Single(stunt.Behaviors);
        }
Example #3
0
        public void WhenAddingStuntBehaviorToObject_ThenCanAddLambda()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);

            Assert.Single(((IStunt)stunt).Behaviors);
        }
Example #4
0
        public void WhenAddingStuntBehaviorToObject_ThenCanAddLambdaWithAppliesTo()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null, m => true);

            Assert.True(((IStunt)stunt).Behaviors[0].AppliesTo(null));
        }
Example #5
0
        public void WhenAddingStuntBehavior_ThenCanAddLambdaWithAppliesTo()
        {
            var stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null, m => true);

            Assert.True(stunt.Behaviors[0].AppliesTo(null));
        }
Example #6
0
        public void WhenAddingStuntBehavior_ThenCanAddInterface()
        {
            var stunt = new TestStunt();

            stunt.AddBehavior(new TestStuntBehavior());

            Assert.Single(stunt.Behaviors);
        }
Example #7
0
        public void WhenAddingStuntBehavior_ThenCanCustom()
        {
            IStunt stunt = new TestStunt();

            stunt.AddBehavior(new TestStuntBehavior());

            Assert.Single(stunt.Behaviors);
        }
Example #8
0
        public void WhenInsertingStuntBehavior_ThenCanAddLambda()
        {
            var stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, (m, n) => throw new NotImplementedException());

            Assert.Equal(2, stunt.Behaviors.Count);
            Assert.Throws <NotImplementedException>(() => stunt.Behaviors[0].Execute(null, null));
        }
Example #9
0
        public void WhenInsertingStuntBehaviorToObject_ThenCanAddLambda()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, (m, n) => throw new NotImplementedException());

            Assert.Equal(2, ((IStunt)stunt).Behaviors.Count);
            Assert.Throws <NotImplementedException>(() => ((IStunt)stunt).Behaviors[0].Invoke(null, null));
        }
Example #10
0
        public void WhenAddingStuntBehaviorToObject_ThenCanAddLambdaWithAppliesToNamed()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null, m => true, "true");
            ((IStunt)stunt).AddBehavior((m, n) => null, m => false, "false");

            Assert.Contains("true", ((IStunt)stunt).Behaviors[0].ToString());
            Assert.Contains("false", ((IStunt)stunt).Behaviors[1].ToString());
        }
Example #11
0
        public void WhenInsertingStuntBehavior_ThenCanCustom()
        {
            IStunt stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, new TestStuntBehavior());

            Assert.Equal(2, stunt.Behaviors.Count);
            Assert.IsType <TestStuntBehavior>(stunt.Behaviors[0]);
        }
Example #12
0
        public void WhenInsertingStuntBehavior_ThenCanAddInterface()
        {
            var stunt    = new TestStunt();
            var behavior = new TestStuntBehavior();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, behavior);

            Assert.Equal(2, stunt.Behaviors.Count);
            Assert.Same(behavior, stunt.Behaviors[0]);
        }
Example #13
0
        public void WhenInsertingStuntBehaviorToObject_ThenCanAddLambdaWithAppliesToNamed()
        {
            object stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, (m, n) => throw new NotImplementedException(), m => true, "true");
            ((IStunt)stunt).InsertBehavior(0, (m, n) => throw new ArgumentException(), m => false, "false");

            Assert.Equal(3, ((IStunt)stunt).Behaviors.Count);
            Assert.Contains("false", ((IStunt)stunt).Behaviors[0].ToString());
            Assert.Contains("true", ((IStunt)stunt).Behaviors[1].ToString());
        }
Example #14
0
        public void WhenInsertingStuntBehavior_ThenCanAddLambdaWithAppliesTo()
        {
            var stunt = new TestStunt();

            stunt.AddBehavior((m, n) => null);
            stunt.InsertBehavior(0, (m, n) => throw new NotImplementedException(), m => true);
            stunt.InsertBehavior(0, (m, n) => throw new ArgumentException(), m => false);

            Assert.Equal(3, stunt.Behaviors.Count);
            Assert.False(stunt.Behaviors[0].AppliesTo(null));
            Assert.True(stunt.Behaviors[1].AppliesTo(null));
            Assert.Throws <NotImplementedException>(() => stunt.Behaviors[1].Execute(null, null));
        }