public void CreateTestOnIndex()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();
            MembersController target = null;
            try
            {
                target = new MembersController(accountsMngService);

                ActionResult actual;

                using (mocks.Record())
                {

                }

                using (mocks.Playback())
                {
                    actual = target.Create();
                }

                Helpers.ControllerTestHelper.TestForEmptyViewAndModel(actual, target);
            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }
        }
        public void CreateTestWithEmptyModel()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();
            CreateMemberViewModel model = mocks.StrictMock<CreateMemberViewModel>();
            MembersController target = null;
            ViewResult actual;

            try
            {
                target = new MembersController(accountsMngService);

                //Assert init
                Assert.AreEqual(0, target.ModelState.Count);

                Helpers.ControllerTestHelper.MimicValidation(model, target);

                using (mocks.Record())
                {

                }

                //Act
                using (mocks.Playback())
                {
                    actual = (ViewResult) target.Create(model);
                }
            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }

            //Assert result
            Assert.AreEqual(3, actual.ViewData.ModelState.Count);
            Assert.IsTrue(actual.ViewData.ModelState.ContainsKey("username"));
            Assert.IsTrue(actual.ViewData.ModelState.ContainsKey("password"));
            Assert.IsTrue(actual.ViewData.ModelState.ContainsKey("email"));
        }
        public void MembersControllerConstructorTest()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();

            using (mocks.Record())
            {

            }

            using (mocks.Playback())
            {
                MembersController target = new MembersController(accountsMngService);
                target.Dispose();
            }
        }
        public void CreateTestWithUserNameOneLetterAndPasswordTenLetterAndValidConfirmAndValidEmailAndProviderSuccessResult()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();
            CreateMemberViewModel model = mocks.StrictMock<CreateMemberViewModel>();
            model.UserName = "******";
            model.Password = "******";
            model.ConfirmPassword = "******";
            model.Email = "*****@*****.**";
            MembersController target = null;
            ActionResult actual;

            try
            {
                target = new MembersController(accountsMngService);

                //Assert init
                Assert.AreEqual(0, target.ModelState.Count);

                Helpers.ControllerTestHelper.MimicValidation(model, target);

                using (mocks.Record())
                {
                    Expect.Call(accountsMngService.CreateMember(model)).Return(MembershipCreateStatus.Success);
                }

                //Act
                using (mocks.Playback())
                {
                    actual = target.Create(model);
                }

            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }

            //Assert result
            Assert.AreEqual(0, target.ModelState.Count);
            Assert.IsInstanceOfType(actual, typeof(RedirectToRouteResult));

            RedirectToRouteResult typedResult = (RedirectToRouteResult)actual;

            Assert.IsFalse(typedResult.Permanent);
            Assert.AreEqual("", typedResult.RouteName);

            Assert.IsTrue(typedResult.RouteValues.ContainsKey("area"));
            Assert.IsTrue(typedResult.RouteValues.ContainsKey("controller"));
            Assert.IsTrue(typedResult.RouteValues.ContainsKey("action"));

            Assert.AreEqual("SymNet", typedResult.RouteValues["area"]);
            Assert.AreEqual("Members", typedResult.RouteValues["controller"]);
            Assert.AreEqual("Create", typedResult.RouteValues["action"]);
        }
        public void CreateTestWithUserNameOneLetterAndPasswordTenLetterAndValidConfirmAndInvalidEmail()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();
            CreateMemberViewModel model = mocks.StrictMock<CreateMemberViewModel>();
            model.UserName = "******";
            model.Password = "******";
            model.ConfirmPassword = "******";
            model.Email = "t@";
            MembersController target = null;
            ViewResult actual;

            try
            {
                target = new MembersController(accountsMngService);

                //Assert init
                Assert.AreEqual(0, target.ModelState.Count);

                Helpers.ControllerTestHelper.MimicValidation(model, target);

                using (mocks.Record())
                {

                }

                //Act
                using (mocks.Playback())
                {
                    actual = (ViewResult)target.Create(model);
                }

            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }

            //Assert result
            Assert.AreEqual(1, actual.ViewData.ModelState.Count);
            Assert.IsTrue(actual.ViewData.ModelState.ContainsKey("email")); //Email invalid
        }
        public void CreateTestWithUserNameOneLetterAndPasswordTenLetterAndAndValidConfirmAndValidEmailAndProviderErrorResult()
        {
            MembershipCreateStatus[] test = {MembershipCreateStatus.DuplicateProviderUserKey,
                                             MembershipCreateStatus.InvalidAnswer,
                                             MembershipCreateStatus.InvalidProviderUserKey,
                                             MembershipCreateStatus.InvalidQuestion,
                                             MembershipCreateStatus.DuplicateEmail,
                                             MembershipCreateStatus.DuplicateUserName,
                                             MembershipCreateStatus.InvalidEmail,
                                             MembershipCreateStatus.InvalidPassword,
                                             MembershipCreateStatus.InvalidUserName,
                                             MembershipCreateStatus.ProviderError,
                                             MembershipCreateStatus.UserRejected};
            foreach (MembershipCreateStatus it in test)
            {

                // Arrange
                MockRepository mocks = new MockRepository();
                IMembersContainerService accountsMngService = mocks.StrictMock<IMembersContainerService>();
                CreateMemberViewModel model = mocks.StrictMock<CreateMemberViewModel>();
                model.UserName = "******";
                model.Password = "******";
                model.ConfirmPassword = "******";
                model.Email = "*****@*****.**";
                MembersController target = null;
                ViewResult actual;

                try
                {
                    target = new MembersController(accountsMngService);

                    //Assert init
                    Assert.AreEqual(0, target.ModelState.Count);

                    Helpers.ControllerTestHelper.MimicValidation(model, target);

                    using (mocks.Record())
                    {
                        Expect.Call(accountsMngService.CreateMember(model)).Return(it);
                    }

                    //Act
                    using (mocks.Playback())
                    {
                        actual = (ViewResult)target.Create(model);
                    }

                }
                finally
                {
                    if (target != null)
                    {
                        target.Dispose();
                    }
                }

                //Assert result
                Assert.AreEqual(1, actual.ViewData.ModelState.Count);
                Assert.IsInstanceOfType(actual, typeof(ViewResult));
            }
        }