Example #1
0
        public void OnlyLastResultReturned()
        {
            FunctionalTricks f      = new FunctionalTricks();
            Curry            adding = f.Add5;

            adding += f.Add10;
            //Delegates may have more than one method attached, but only the result of the last method is returned.
            Assert.Equal(15, adding(5));
        }
        public void RemovingMethods()
        {
            FunctionalTricks f      = new FunctionalTricks();
            Curry            adding = f.Add5;

            adding += f.Add10;
            Assert.Equal(2, adding.GetInvocationList().Length);
            //Remove Add5 from the invocation list
            Assert.Equal(1, adding.GetInvocationList().Length);
            Assert.Equal("Add10", adding.GetMethodInfo().Name);
        }
        public void DelegatesHaveAnInvocationList()
        {
            FunctionalTricks f      = new FunctionalTricks();
            Curry            adding = f.Add5;

            //So far we've only seen one method attached to a delegate.
            Assert.Equal(FILL_ME_IN, adding.GetInvocationList().Length);
            //However, you can attach multiple methods to a delegate
            adding += f.Add10;
            Assert.Equal(FILL_ME_IN, adding.GetInvocationList().Length);
        }
        public void RemovingMethods()
        {
            FunctionalTricks f      = new FunctionalTricks();
            Curry            adding = f.Add5;

            adding += f.Add10;
            Assert.Equal(2, adding.GetInvocationList().Length);
            adding -= f.Add5;
            Assert.Equal(1, adding.GetInvocationList().Length);
            Assert.Equal("Add10", adding.Method.Name);
        }
 public void RemovingMethods()
 {
     FunctionalTricks f = new FunctionalTricks();
     Curry adding = f.Add5;
     adding += f.Add10;
     Assert.Equal(2, adding.GetInvocationList().Length);
     //Remove Add5 from the invocation list
     Assert.Equal(2, adding.GetInvocationList().Length);
     Assert.Equal("Add10", adding.Method.Name);
 }
 public void OnlyLastResultReturned()
 {
     FunctionalTricks f = new FunctionalTricks();
     Curry adding = f.Add5;
     adding += f.Add10;
     //Delegates may have more than one method attached, but only the result of the last method is returned.
     Assert.Equal(15, adding(5));
 }
 public void DelegatesHaveAnInvocationList()
 {
     FunctionalTricks f = new FunctionalTricks();
     Curry adding = f.Add5;
     //So far we've only seen one method attached to a delegate.
     Assert.Equal(1, adding.GetInvocationList().Length);
     //However, you can attach multiple methods to a delegate
     adding += f.Add10;
     Assert.Equal(2, adding.GetInvocationList().Length);
 }