Exemple #1
0
        public void ConsoleConstrollerAddCommandAddsCommand()
        {
            // MSTest Extended
            ConsoleController controller = new ConsoleController();

            controller.AddCommand("SayGoodbye", s => Console.WriteLine("Goodbye " + s));

            ConsoleAssert.WritesOut(
                () => controller.HandleInput("SayGoodbye World"),
                "Goodbye World");

            // TestTools Code
            UnitTest test = Factory.CreateTest();
            TestVariable <ConsoleController> _controller = test.CreateVariable <ConsoleController>();

            test.Arrange(_controller, Expr(() => new ConsoleController()));
            test.Act(Expr(_controller, (c) => c.AddCommand("SayGoodbye", s => Console.WriteLine("Goodbye " + s))));
            test.ConsoleAssert.WritesOut(
                Lambda(Expr(_controller, c => c.HandleInput("SayGoodbye World"))),
                Const("Goodbye World"));
            test.Execute();
        }