Exemplo n.º 1
0
        public void ConsoleViewRunEmitsInputOnNonEmptyLineInput()
        {
            bool        isCalled = false;
            ConsoleView view     = new ConsoleView();

            view.Input += (input) => isCalled = true;

            ConsoleInputter.Clear();
            ConsoleInputter.WriteLine("User input");
            ConsoleInputter.WriteLine();
            view.Run();

            Assert.IsTrue(isCalled, "The ConsoleView.Run event was never emitted");

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

            test.Arrange(_view, Expr(() => new ConsoleView()));
            test.DelegateAssert.IsInvoked(Lambda <InputHandler>(handler => Expr(_view, v => v.AddInput(handler))));
            test.Act(Expr(() => ConsoleInputter.Clear()));
            test.Act(Expr(() => ConsoleInputter.WriteLine("User input")));
            test.Act(Expr(() => ConsoleInputter.WriteLine()));
            test.Act(Expr(_view, v => v.Run()));
            test.Execute();
        }
Exemplo n.º 2
0
        public void ConsoleViewRunReturnsOnEmptyLineInput()
        {
            // MSTest Extended
            ConsoleView view = new ConsoleView();

            ConsoleInputter.Clear();
            ConsoleInputter.WriteLine();
            view.Run();

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

            test.Arrange(_view, Expr(() => new ConsoleView()));
            test.Act(Expr(() => ConsoleInputter.Clear()));
            test.Act(Expr(() => ConsoleInputter.WriteLine()));
            test.Act(Expr(_view, v => v.Run()));
            test.Execute();
        }