public void SignUp_RedirectsGetToHome() { var controller = new SignUpController(configuration, signUpQueueingService, charityMembershipService); var result = controller.SignUp(); result.AssertActionRedirect(); }
private async void _SignUp_Clicked(object sender, EventArgs e) { Dictionary <int, String[]> KeyValues = new Dictionary <int, string[]>(); bool IsCompleted = false; try { KeyValues.Add(0, new String[] { "full_name", _FullName.Text }); KeyValues.Add(1, new String[] { "gender", (_Gender.SelectedItem.Equals("Male")) ? "m" : "f" }); KeyValues.Add(2, new String[] { "phone", GD.Phone }); KeyValues.Add(3, new String[] { "address", _HomeAddress.Text }); KeyValues.Add(4, new String[] { "dob", _DOB.Date.ToString("yyyy-MM-dd") }); KeyValues.Add(5, new String[] { "password", GD.Password }); KeyValues.Add(6, new String[] { "username", _Username.Text }); if (!String.IsNullOrEmpty(GD.Email)) { KeyValues.Add(7, new String[] { "email", GD.Email }); } KeyValues.Add(8, new String[] { "blood_group", _BloodGroup.SelectedItem.ToString() }); KeyValues.Add(9, new String[] { "is_medic", "0" }); IsCompleted = true; } catch { await DisplayAlert("Alert", "Please Fill All Fields", "Okay"); } if (IsCompleted) { FormUrlEncodedContent Data = Utilities.PostDataEncoder(KeyValues); try { //get the result of the signup 0 = status, 1 = message var Result = await SignUpController.SignUp(Data); if (Convert.ToBoolean(Result[0])) { await Utilities.CreateAlertDialog("Alert", Result[1].ToString(), "Ok", delegate { Navigation.PushAsync(new LoginPage()); Navigation.RemovePage(this); }); } else { await DisplayAlert("Alert", Result[1].ToString(), "Okay"); } } catch (System.Net.WebException WebEx) { await DisplayAlert("Alert", "Unable to connect to the server, Please check the internet connection. ", "Okay"); } catch (Exception ex) { await DisplayAlert("Alert", "UPDP Error, Please Contact Admin " + ex.Message, "Okay"); } } }
public void SignUp_ModelStateNotValid() { SignUpController controller = new SignUpController(_userRepoMock.Object); SignUp signUpUser = new SignUp(); SetModelState(signUpUser, controller); ActionResult result = controller.SignUp(signUpUser); Assert.IsNotNull(result); Assert.IsTrue(result is ViewResult); Assert.IsTrue((result as ViewResult).ViewName == "Index"); }
public void SignUp_WithUnsuccessfulStore_RendersView() { var requiredInfoViewModel = new RequiredInfoViewModel { UserIdentifier = "A", Password = "******", CharityName = "C", }; var controller = new SignUpController(configuration, signUpQueueingService, charityMembershipService); charityMembershipService.RegisterUserAndCharity(null).ReturnsForAnyArgs(false); var result = controller.SignUp(requiredInfoViewModel); result.AssertViewRendered(); }
public void SignUp_WithSuccessfulStore_RedirectsToComplete() { var requiredInfoViewModel = new RequiredInfoViewModel { UserIdentifier = "A", Password = "******", CharityName = "C", }; var controller = new SignUpController(configuration, signUpQueueingService, charityMembershipService); charityMembershipService.RegisterUserAndCharity(null).ReturnsForAnyArgs(true); var result = controller.SignUp(requiredInfoViewModel); result.AssertActionRedirect().ToAction("Complete"); }
public void SignUp_CreateFailed() { SignUpController controller = new SignUpController(_userRepoMock.Object); SignUp signUpUser = new SignUp(); signUpUser.FirstName = "Naruto"; signUpUser.LastName = "Uzumaki"; signUpUser.Email = "*****@*****.**"; signUpUser.Password = "******"; SetModelState(signUpUser, controller); _userRepoMock.Setup(m => m.Create(It.IsAny <User>())).Returns(false); ActionResult result = controller.SignUp(signUpUser); Assert.IsNotNull(result); Assert.IsTrue(result is ViewResult); Assert.IsTrue((result as ViewResult).ViewName == "Index"); Assert.IsTrue(controller.TempData.ContainsKey("notification")); Assert.IsTrue(controller.TempData["notification"] is Notification); Assert.IsTrue((controller.TempData["notification"] as Notification).Type == NotificationType.Error); }
public void SignUp() { SignUpController controller = new SignUpController(_userRepoMock.Object); SignUp signUpUser = new SignUp(); signUpUser.FirstName = "Naruto"; signUpUser.LastName = "Uzumaki"; signUpUser.Email = "*****@*****.**"; signUpUser.Password = "******"; SetModelState(signUpUser, controller); _userRepoMock.Setup(m => m.Create(It.IsAny <User>())).Returns(true); ActionResult result = controller.SignUp(signUpUser); Assert.IsNotNull(result); Assert.IsTrue(result is RedirectToRouteResult); Assert.IsTrue((result as RedirectToRouteResult).RouteValues.ContainsKey("action")); Assert.IsTrue((result as RedirectToRouteResult).RouteValues.ContainsKey("controller")); Assert.IsTrue((result as RedirectToRouteResult).RouteValues["action"].ToString() == "Index"); Assert.IsTrue((result as RedirectToRouteResult).RouteValues["controller"].ToString() == "Home"); }