Exemple #1
0
        public async Task ShouldNavigateToConfirmationPage()
        {
            var accountService = new Mock <IAccountService>();

            accountService.Setup(s => s.SignUp(It.IsAny <SignUpRequest>())).ReturnsAsync(new SignUpResponseModel(1)).Verifiable();

            viewService
            .Setup(m => m.SetCurrentPage(It.Is((BaseViewModel p) => p.GetType() == typeof(ConfirmationCodeEntryViewModel))))
            .Verifiable();

            ConfirmationCodeEntryViewModel CreateConfirmationCodeEntryViewModel(int requestId)
            => new ConfirmationCodeEntryViewModel(requestId, null, null, null, null, null, null);

            var viewModel = new SignUpPageViewModel(accountService.Object, CreateConfirmationCodeEntryViewModel, dataFlow.Object, viewService.Object, () => phoneService.Object, deviceInfo.Object, connectivity.Object, appInfo.Object)
            {
                View         = view.Object,
                FirstName    = { Value = "Jhon" },
                LastName     = { Value = "Smith" },
                MobileNumber = { Value = "+614245373" },
                EmailAddress = { Value = "*****@*****.**" }
            };

            Assert.True(viewModel.CanSignUp());

            await viewModel.SignUp();

            // Assert that there is a naviation call to confirmation page
            viewService.Verify();

            accountService.Verify();
        }
        private async void registrationButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                var prxCustomer = await _viewModel.SignUp();

                if (prxCustomer.ResultCode == 1)
                {
                    await Navigation.PopAsync(true);
                }
                else
                {
                    await DisplayAlert("Error", prxCustomer.ResultMessage, "OK");
                }
                _viewModel.Reset();
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
        }