Example #1
0
        public void When_SigningUpCalled_ReturnSignUpView()
        {
            // Act
            ViewResult result = _signUpController.SigningUp() as ViewResult;

            // Assert
            Assert.That(result.ViewBag.Message, Is.EqualTo("SignUp Page"));
        }
Example #2
0
        public void GivenInvalidSignUpDetails_WhenSigningUpCalled_RedirectToProfile()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                _signUpController = scope.Resolve <SignUpController>();
                _profileService   = scope.Resolve <ProfileService>();

                var userDetails = new UserSignUpViewModel();

                // Act
                var result = _signUpController.SigningUp(userDetails) as ViewResult;

                // Assert
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Model);
                Assert.IsInstanceOf <UserSignUpViewModel>(result.Model);
                Assert.That(result.ViewBag.Message, Is.EqualTo("Error in SignUp Occured"));
            }
        }
Example #3
0
        public void GivenValidSignUpDetails_WhenSigningUpCalled_RedirectToProfile()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                _signUpController = scope.Resolve <SignUpController>();
                _profileService   = scope.Resolve <ProfileService>();

                var userDetails = new UserSignUpViewModel();

                userDetails.FirstName       = "Bill";
                userDetails.LastName        = "Murray";
                userDetails.City            = "Tokyo";
                userDetails.Country         = "Japan";
                userDetails.Email           = "*****@*****.**";
                userDetails.Password        = "******";
                userDetails.ConfirmPassword = userDetails.Password;
                userDetails.DOB             = "1990-10-10 00:00:00.000";

                var fakeHttpContext = A.Fake <HttpContextBase>();
                var session         = A.Fake <HttpSessionStateBase>();
                session["userId"] = 7;
                A.CallTo(() => fakeHttpContext.Session).Returns(session);
                ControllerContext context = new ControllerContext(new RequestContext(fakeHttpContext, new RouteData()),
                                                                  _signUpController);

                _signUpController.ControllerContext = context;

                // Act
                var result = _signUpController.SigningUp(userDetails) as RedirectToRouteResult;

                // Assert
                Assert.IsNotNull(result);
                var values = result.RouteValues.Values;

                Assert.IsNotNull(values);
                Assert.IsTrue(values.Contains("Profiles"));
                Assert.IsTrue(values.Contains("MyProfile"));
            }
        }