Esempio n. 1
0
        public void WhenAddingProxyBehaviorToObject_ThenCanAddInterface()
        {
            object proxy = new TestProxy();

            proxy.AddBehavior(new TestProxyBehavior());

            Assert.Equal(1, ((IProxy)proxy).Behaviors.Count);
        }
Esempio n. 2
0
        public void WhenAddingProxyBehaviorToObject_ThenCanAddLambdaWithAppliesTo()
        {
            object proxy = new TestProxy();

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

            Assert.True(((IProxy)proxy).Behaviors[0].AppliesTo(null));
        }
Esempio n. 3
0
        public void WhenAddingProxyBehaviorToObject_ThenCanAddLambda()
        {
            object proxy = new TestProxy();

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

            Assert.Equal(1, ((IProxy)proxy).Behaviors.Count);
        }
Esempio n. 4
0
        public void WhenAddingProxyBehavior_ThenCanAddInterface()
        {
            var proxy = new TestProxy();

            proxy.AddBehavior(new TestProxyBehavior());

            Assert.Equal(1, proxy.Behaviors.Count);
        }
Esempio n. 5
0
        public void WhenAddingProxyBehavior_ThenCanAddLambdaWithAppliesTo()
        {
            var proxy = new TestProxy();

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

            Assert.True(proxy.Behaviors[0].AppliesTo(null));
        }
Esempio n. 6
0
        public void WhenAddingProxyBehavior_ThenCanAddLambda()
        {
            var proxy = new TestProxy();

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

            Assert.Equal(1, proxy.Behaviors.Count);
        }
Esempio n. 7
0
        public void WhenInsertingProxyBehavior_ThenCanAddLambda()
        {
            var proxy = new TestProxy();

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

            Assert.Equal(2, proxy.Behaviors.Count);
            Assert.Throws <NotImplementedException>(() => proxy.Behaviors[0].Invoke(null, null));
        }
Esempio n. 8
0
        public void WhenInsertingProxyBehavior_ThenCanAddInterface()
        {
            var proxy    = new TestProxy();
            var behavior = new TestProxyBehavior();

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

            Assert.Equal(2, proxy.Behaviors.Count);
            Assert.Same(behavior, proxy.Behaviors[0]);
        }
Esempio n. 9
0
        public void WhenInsertingProxyBehavior_ThenCanAddLambdaWithAppliesTo()
        {
            var proxy = new TestProxy();

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

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