Exemplo n.º 1
0
        public void ComposeMultipleFunctionsRightAfterLeft()
        {
            Func <int, int> add1       = x => x + 1;
            Func <int, int> times2     = x => x * 2;
            Func <int, int> square     = x => x * x;
            Func <int, int> subtract10 = x => x - 10;

            Func <int, int> expectedComposed = x => (((x + 1) * 2) * ((x + 1) * 2)) - 10;

            Func <int, int> composed =
                Fn.ComposeReverse(add1, times2, square, subtract10);

            Assert.That(composed(12), Is.EqualTo(expectedComposed(12)));
            Assert.That(composed(12), Is.EqualTo(666));
        }