Exemplo n.º 1
0
        public void LensCompositionTet()
        {
            var moveTurtle = from x in TurtleX.ModS(x => x + 10)
                             from y in TurtleY.ModS(y => y + 10)
                             select Tuple.Create(x, y);

            var turtle1 = new Turtle("bob", new Position(x: 10, y: -2));

            var result = moveTurtle.Run(turtle1);

            Console.WriteLine(result);

            Assert.AreEqual(result.Item2.Item1, 20);
            Assert.AreEqual(result.Item2.Item2, 8);
        }
Exemplo n.º 2
0
        public void LensReadTest()
        {
            var nameAndPosition = from name in TurtleName.GetS()
                                  from x in TurtleX.GetS()
                                  from y in TurtleY.GetS()
                                  select Tuple.Create(name, x, y);

            var turtle1 = new Turtle("bob", new Position(x: 10, y: -2));

            var result = nameAndPosition.Eval(turtle1);

            Console.WriteLine(result);

            Assert.AreEqual("bob", result.Item1);
            Assert.AreEqual(10, result.Item2);
            Assert.AreEqual(-2, result.Item3);
        }