Exemplo n.º 1
0
        public void TransactionMenuKeypadCancel()
        {
            this.TestContext.WriteLine("Given");
            this.TestContext.WriteLine("* A user is viewing the transaction menu");
            this.TestContext.WriteLine("When");
            this.TestContext.WriteLine("* An Keypad Cancel is pressed");
            this.TestContext.WriteLine("Then");
            this.TestContext.WriteLine("* The transaction menu should exit");
            this.TestContext.WriteLine("Test scenario completed in Exercise 4");

            var testViewModel = new TestAtmViewModel();
            var atmMachine    = new AtmMachine(testViewModel);

            try
            {
                // Turn the power on
                atmMachine.TurnPowerOn().WaitForWorkflow();

                // Insert an valid card
                atmMachine.InsertCard(true).WaitForWorkflow();

                // Enter a pin ends with Keypad Enter
                atmMachine.AcceptPin("1234").WaitForWorkflow();

                // Cancel at the transaction menu
                atmMachine.Cancel().WaitForWorkflow();

                // Turn off the ATM
                atmMachine.TurnPowerOff().Wait();

                // Verify the states
                AssertState.OccursInOrder(
                    "Transaction Menu StateMachine", testViewModel.Records, TransactionMenuState.TransactionMenu, TransactionMenuState.Exit);

                AssertState.OccursInOrder(
                    "ATM StateMachine", testViewModel.Records, AtmState.Initialize, AtmState.InsertCard, AtmState.EnterPin, AtmState.MainMenu);

                // Verify the transitions
                AssertHelper.OccursInOrder(
                    "Transitions",
                    testViewModel.Transitions,
                    AtmTransition.PowerOn,
                    AtmTransition.CardInserted,
                    AtmTransition.KeypadEnter,
                    AtmTransition.KeypadCancel,
                    AtmTransition.PowerOff);

                // Verify the prompts
                AssertHelper.OccursInOrder(
                    "Prompts", testViewModel.Prompts.ConvertAll((prompt) => prompt.Text), Prompts.PleaseWait, Prompts.InsertCard, Prompts.EnterYourPin);

                // Verify the valid card
                Assert.AreEqual(1, testViewModel.CardReaderResults.Count);
                Assert.AreEqual(CardStatus.Valid, testViewModel.CardReaderResults[0].CardStatus);

                // Verify the exit action cleared the screen at least twice
                Assert.IsTrue(testViewModel.ClearCount >= 4, "Verify that you added the ClearView activity to the Exit Action of states that require it");

                // Verify the camera control
                AssertHelper.OccursInOrder("CameraControl", testViewModel.CameraControl, true);
            }
            finally
            {
                testViewModel.Trace(this.TestContext);
            }
        }
        public void TransactionMenuKeypadCancel()
        {
            this.TestContext.WriteLine("Given");
            this.TestContext.WriteLine("* A user is viewing the transaction menu");
            this.TestContext.WriteLine("When");
            this.TestContext.WriteLine("* An Keypad Cancel is pressed");
            this.TestContext.WriteLine("Then");
            this.TestContext.WriteLine("* The transaction menu should exit");
            this.TestContext.WriteLine("Test scenario completed in Exercise 4");

            var testViewModel = new TestAtmViewModel();
            var atmMachine = new AtmMachine(testViewModel);

            try
            {
                // Turn the power on
                atmMachine.TurnPowerOn().WaitForWorkflow();

                // Insert an valid card
                atmMachine.InsertCard(true).WaitForWorkflow();

                // Enter a pin ends with Keypad Enter
                atmMachine.AcceptPin("1234").WaitForWorkflow();

                // Cancel at the transaction menu
                atmMachine.Cancel().WaitForWorkflow();

                // Turn off the ATM
                atmMachine.TurnPowerOff().Wait();

                // Verify the states
                AssertState.OccursInOrder(
                    "Transaction Menu StateMachine", testViewModel.Records, TransactionMenuState.TransactionMenu, TransactionMenuState.Exit);

                AssertState.OccursInOrder(
                    "ATM StateMachine", testViewModel.Records, AtmState.Initialize, AtmState.InsertCard, AtmState.EnterPin, AtmState.MainMenu);

                // Verify the transitions
                AssertHelper.OccursInOrder(
                    "Transitions",
                    testViewModel.Transitions,
                    AtmTransition.PowerOn,
                    AtmTransition.CardInserted,
                    AtmTransition.KeypadEnter,
                    AtmTransition.KeypadCancel,
                    AtmTransition.PowerOff);

                // Verify the prompts
                AssertHelper.OccursInOrder(
                    "Prompts", testViewModel.Prompts.ConvertAll((prompt) => prompt.Text), Prompts.PleaseWait, Prompts.InsertCard, Prompts.EnterYourPin);

                // Verify the valid card
                Assert.AreEqual(1, testViewModel.CardReaderResults.Count);
                Assert.AreEqual(CardStatus.Valid, testViewModel.CardReaderResults[0].CardStatus);

                // Verify the exit action cleared the screen at least twice
                Assert.IsTrue(testViewModel.ClearCount >= 4, "Verify that you added the ClearView activity to the Exit Action of states that require it");

                // Verify the camera control
                AssertHelper.OccursInOrder("CameraControl", testViewModel.CameraControl, true);
            }
            finally
            {
                testViewModel.Trace(this.TestContext);
            }
        }
Exemplo n.º 3
0
        public void EnterPinTriggerKeypadCancelToRemoveCard()
        {
            this.TestContext.WriteLine("Given");
            this.TestContext.WriteLine("* The ATM Machine");
            this.TestContext.WriteLine("* In the Enter Pin state");
            this.TestContext.WriteLine("When");
            this.TestContext.WriteLine("* An Keypad Cancel is pressed");
            this.TestContext.WriteLine("Then");
            this.TestContext.WriteLine("* The StateMachine enters the Remove Card state");
            this.TestContext.WriteLine("Test scenario completed in Exercise 3");

            var testViewModel = new TestAtmViewModel();
            var atmMachine    = new AtmMachine(testViewModel);

            try
            {
                // Turn the power on
                atmMachine.TurnPowerOn().WaitForWorkflow();

                // Insert an valid card
                atmMachine.InsertCard(true).WaitForWorkflow();

                // Enter a pin ends with Keypad Enter
                atmMachine.Cancel().WaitForWorkflow();

                // Turn off the ATM
                atmMachine.TurnPowerOff().Wait();

                // Verify the first three states occurred in the correct order.
                // Make sure you set the state name correctly
                AssertState.OccursInOrder(
                    "ATM StateMachine", testViewModel.Records, AtmState.Initialize, AtmState.InsertCard, AtmState.EnterPin, AtmState.RemoveCard);

                // Verify that you added an InitializeAtm activity to the Entry actions of the Initialize State
                AssertHelper.OccursInOrder(
                    "Transitions",
                    testViewModel.Transitions,
                    AtmTransition.PowerOn,
                    AtmTransition.CardInserted,
                    AtmTransition.KeypadCancel,
                    AtmTransition.PowerOff);

                // Verify the prompts
                AssertHelper.OccursInOrder(
                    "Prompts",
                    testViewModel.Prompts.ConvertAll((prompt) => prompt.Text),
                    Prompts.PleaseWait,
                    Prompts.InsertCard,
                    Prompts.EnterYourPin,
                    Prompts.RemoveCard);

                // Verify the valid card
                Assert.AreEqual(1, testViewModel.CardReaderResults.Count);
                Assert.AreEqual(CardStatus.Valid, testViewModel.CardReaderResults[0].CardStatus);

                // Verify the exit action cleared the screen at least twice
                Assert.IsTrue(testViewModel.ClearCount >= 2, "Verify that you added a ClearView activity to the Exit Action of the Initialize State");

                // Verify the camera control
                AssertHelper.OccursInOrder("CameraControl", testViewModel.CameraControl, true);
            }
            finally
            {
                testViewModel.Trace(this.TestContext);
            }
        }
        public void EnterPinTriggerKeypadCancelToRemoveCard()
        {
            this.TestContext.WriteLine("Given");
            this.TestContext.WriteLine("* The ATM Machine");
            this.TestContext.WriteLine("* In the Enter Pin state");
            this.TestContext.WriteLine("When");
            this.TestContext.WriteLine("* An Keypad Cancel is pressed");
            this.TestContext.WriteLine("Then");
            this.TestContext.WriteLine("* The StateMachine enters the Remove Card state");
            this.TestContext.WriteLine("Test scenario completed in Exercise 3");

            var testViewModel = new TestAtmViewModel();
            var atmMachine = new AtmMachine(testViewModel);

            try
            {
                // Turn the power on
                atmMachine.TurnPowerOn().WaitForWorkflow();

                // Insert an valid card
                atmMachine.InsertCard(true).WaitForWorkflow();

                // Enter a pin ends with Keypad Enter
                atmMachine.Cancel().WaitForWorkflow();

                // Turn off the ATM
                atmMachine.TurnPowerOff().Wait();

                // Verify the first three states occurred in the correct order.
                // Make sure you set the state name correctly
                AssertState.OccursInOrder(
                    "ATM StateMachine", testViewModel.Records, AtmState.Initialize, AtmState.InsertCard, AtmState.EnterPin, AtmState.RemoveCard);

                // Verify that you added an InitializeAtm activity to the Entry actions of the Initialize State
                AssertHelper.OccursInOrder(
                    "Transitions",
                    testViewModel.Transitions,
                    AtmTransition.PowerOn,
                    AtmTransition.CardInserted,
                    AtmTransition.KeypadCancel,
                    AtmTransition.PowerOff);

                // Verify the prompts
                AssertHelper.OccursInOrder(
                    "Prompts",
                    testViewModel.Prompts.ConvertAll((prompt) => prompt.Text),
                    Prompts.PleaseWait,
                    Prompts.InsertCard,
                    Prompts.EnterYourPin,
                    Prompts.RemoveCard);

                // Verify the valid card
                Assert.AreEqual(1, testViewModel.CardReaderResults.Count);
                Assert.AreEqual(CardStatus.Valid, testViewModel.CardReaderResults[0].CardStatus);

                // Verify the exit action cleared the screen at least twice
                Assert.IsTrue(testViewModel.ClearCount >= 2, "Verify that you added a ClearView activity to the Exit Action of the Initialize State");

                // Verify the camera control
                AssertHelper.OccursInOrder("CameraControl", testViewModel.CameraControl, true);
            }
            finally
            {
                testViewModel.Trace(this.TestContext);
            }
        }