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)); }
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]); }