Exemplo n.º 1
0
        public void GivenUserDetails_WhenAddUserCalled_ReturnTrue()
        {
            // Arrange
            var fakeSignUpViewModel = A.Fake <UserSignUpViewModel>();

            fakeSignUpViewModel.LastName  = _mockUserData.FakeUser1.LastName;
            fakeSignUpViewModel.FirstName = _mockUserData.FakeUser1.FirstName;
            fakeSignUpViewModel.Country   = _mockUserData.FakeUser1.Country;
            fakeSignUpViewModel.City      = _mockUserData.FakeUser1.City;
            fakeSignUpViewModel.Password  = _mockUserData.FakeUser1.Password;
            fakeSignUpViewModel.Email     = _mockUserData.FakeUser1.Email;
            fakeSignUpViewModel.DOB       = "1990-10-10 00:00:00.000";

            var fakeUser = A.Fake <User>();

            A.CallTo(() => _userRepository.Create(A <User> ._)).WithAnyArguments().Returns(true);

            // Act
            var result = _signUpService.AddUser(fakeSignUpViewModel);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <bool>());
            Assert.That(result, Is.EqualTo(true));
            A.CallTo(() => _userRepository.Create(A <User> ._)).MustHaveHappened(Repeated.Exactly.Once);
        }
Exemplo n.º 2
0
        public ActionResult SigningUp(UserSignUpViewModel userSignUpDetails)
        {
            ValidationResult results = _validator.Validate(userSignUpDetails);

            if (results.IsValid)  //  valid signup, update DB and redirect to profile page
            {
                // add new user to db
                _signUpService.AddUser(userSignUpDetails);

                // retrieve newly added user's details from db
                User userProfile = _signUpService.GetUserDetails(userSignUpDetails);
                Session["userId"] = userProfile.UserId;

                return(RedirectToAction("MyProfile", "Profiles"));
            }
            else
            {
                foreach (ValidationFailure failure in results.Errors)
                {
                    ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage);
                }

                ViewBag.Message = "Error in SignUp Occured";
                return(View(userSignUpDetails));
            }
        }
Exemplo n.º 3
0
        public IActionResult SignUpCredentials(SignUpSecondPageViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            ControlsController controlsController = new ControlsController();

            this.ViewBag.AllMonths = controlsController.GetAllMonths();
            signUpService.AddUser(model.FirstName, model.LastName, model.Day, model.Month, model.Year, model.Gender, model.Email, model.Password);

            return(this.View("SignUpResult", model));
        }