Example #1
0
        public void Bind_is_ran_the_correct_number_of_times()
        {
            var count   = 0;
            var counter = Dot.Bind <string, string>((c, rest) =>
            {
                count++;
                return(rest(c));
            });

            counter(() => "hi".ToUpper().ToUpper().ToUpper());
            Assert.AreEqual(4, count);
        }
Example #2
0
        public void Bind_is_inserted_between_____ <T>(Expression <Func <T> > exp, T expected)
        {
            var success = false;
            var insert  = Dot.Bind <object, T>((c, rest) =>
            {
                if (expected.Equals(c))
                {
                    success = true;
                }
                return(rest(c));
            });

            insert(exp);
            Assert.IsTrue(success);
        }
Example #3
0
        public void Bind_does_not_implicitly_change_values()
        {
            var           count  = 0;
            Func <string> lambda = () => "hi";
            var           bind   = Dot.Bind <object, string>((c, rest) =>
            {
                if (count == 0)
                {
                    count++;
                }
                else if (count == 1)
                {
                    Assert.AreEqual <object>(c, lambda);
                    count++;
                }
                else if (count == 2)
                {
                    Assert.AreEqual(c, "hi");
                    count++;
                }
                else if (count == 3)
                {
                    Assert.AreEqual(c, 'h');
                    count++;
                }
                else if (count == 4)
                {
                    Assert.AreEqual(c, "h");
                    count++;
                }
                else if (count == 5)
                {
                    Assert.AreEqual(c, "H");
                    count++;
                }
                else if (count == 6)
                {
                    Assert.AreEqual(c, "I");
                    count++;
                }
                return(rest(c));
            });

            bind(() => lambda()[0].ToString().ToUpper().Replace('H', 'I'));
        }
Example #4
0
 public void Bind_degenerate_case()
 {
     Assert.AreEqual(Dot.Bind <object, object>((x, y) => y(x))(() => "hi"), "hi");
 }