Esempio n. 1
0
        public void windowFilterMustBeInvoked()
        {
            USSDApplication app    = new BaseUSSDApplication();
            Window          window = new Window("startup");

            window.addMessage(new Message("Welcome, please type something"));
            window.setInput(new Input {
                Name = "something"
            });
            app.addWindowFilter(window.getId(), new StartupWindowFirstFilter());
            app.addWindowFilter(window.getId(), new StartupWindowSecondFilter());

            app.addWindow(window);
            app.setStartupWindowId(window.getId());

            USSDRequest request = app.newRequest(TEST_BASE_CODE);

            fillRequest(request);
            USSDResponse response = BantU.executeRequest(app, request);

            Assert.AreEqual("Altered by the second filter", response.getWindow().getMessages()[0]);
        }
Esempio n. 2
0
        private static USSDApplication getTestApp1()
        {
            USSDApplication application = new BaseUSSDApplication();

            //LoginWindow
            Window loginWindow = new Window("login");

            loginWindow.addMessage(new Message("Please introduce your pin code", "msg1"));
            loginWindow.addMenuItem(new MenuItem {
                Description = "Forgot password", TargetWindow = "recoverPassword"
            });
            loginWindow.setInput(new Input {
                Name = "pin"
            });
            loginWindow.setUSSDProcessor(new LoginProcessor());

            //RecoverPasswordWindow
            Window recoverPassword = new Window("recoverPassword");

            recoverPassword.addMessage(new Message("Ops! This is not working yet!"));

            //OperationsWindow
            Window operationsWindow = new Window("operations");

            operationsWindow.addMessage(new Message("Please select an operation", "msg2"));
            operationsWindow.addMenuItem(new MenuItem {
                Description = "Transfers", TargetWindow = "transfers"
            });
            operationsWindow.addMenuItem(new MenuItem {
                Description = "Withdrawal", TargetWindow = "withdrawal"
            });

            //TransfersWindow
            Window transfersWindow = new Window("tranfers");

            transfersWindow.addMessage(new Message("Please select the origin account", "msg3"));
            transfersWindow.addMenuItemsProviders(new TransfersAccountMenuItemsProvider());

            //AmountWindow
            Window amountWindow = new Window("amountWindow");

            amountWindow.addMessage(new Message("Please introduce the amount"));
            amountWindow.setInput(new Input {
                Name = "amount", RegExp = "[0-9]+", OnErrorTargetWindow = "invalidAmount"
            });
            amountWindow.setUSSDProcessor(new AmountWindowProcessor());

            Window invalidAmountWindow = new Window("invalidAmount");

            invalidAmountWindow.addMessage(new Message("Invalid Amount : {{amount}}. Please try again"));

            Window requestSubmitted = new Window("requestSubmited");

            requestSubmitted.addMessage(new Message("Request Submitted Successfully"));

            application.addWindow(loginWindow);
            application.addWindow(recoverPassword);
            application.addWindow(operationsWindow);
            application.addWindow(transfersWindow);
            application.addWindow(amountWindow);
            application.addWindow(invalidAmountWindow);
            application.addWindow(requestSubmitted);
            application.addWindow(recoverPassword);

            application.setStartupWindowId(loginWindow.getId());
            application.activateBaseCode(TEST_BASE_CODE);

            return(application);
        }