public void WhenAddingProxyBehaviorToObject_ThenCanAddInterface()
        {
            object proxy = new TestProxy();

            proxy.AddBehavior(new TestProxyBehavior());

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

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

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

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

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

            proxy.AddBehavior(new TestProxyBehavior());

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

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

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

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

            Assert.Equal(1, proxy.Behaviors.Count);
        }
        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));
        }
        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]);
        }
        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));
        }