Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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]);
        }