public void CompleteTest()
        {
            InstallController target = null;
            // Arrange
            MockRepository mocks = new MockRepository();
            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            ActionResult actual;

            using (mocks.Record())
            {

            }

            try
            {
                target = new InstallController(installerService);
                using (mocks.Playback())
                {
                    actual = target.Complete();
                }

                ControllerTestHelper.TestForEmptyViewAndModel(actual, target);

            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }
        }
        public void InstallControllerConstructorTest()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            using (mocks.Record())
            {

            }

            using (mocks.Playback())
            {
                InstallController target = new InstallController(installerService);
                target.Dispose();
            }
        }
        public void IndexTestWithUserNameValidAndPasswordOneLetter()
        {
            MockRepository mocks = new MockRepository();

            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            InstallController target = new InstallController(installerService);

            InstallViewModel model = mocks.StrictMock<InstallViewModel>();
            model.UserName = "******";
            model.Password = "******";
            ActionResult actual;

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

            ControllerTestHelper.MimicValidation(model, target);

            using (mocks.Record())
            {

            }
            using (mocks.Playback())
            {
                actual = target.Index(model);
            }
            ViewResult actualTyped = Helpers.ControllerTestHelper.TestForEmptyViewNotModel(actual, target, typeof(InstallViewModel), 3);
            Assert.IsTrue(actualTyped.ViewData.ModelState.ContainsKey("email"));
            Assert.IsTrue(actualTyped.ViewData.ModelState.ContainsKey("password"));
            Assert.IsTrue(actualTyped.ViewData.ModelState.ContainsKey("")); //Confirm password
        }
        public void IndexTestWithUserNameAndEmailAndPasswordAndConfirmValidAndSucceedResult()
        {
            MockRepository mocks = new MockRepository();

            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            InstallController target = new InstallController(installerService);

            InstallViewModel model = mocks.StrictMock<InstallViewModel>();
            model.UserName = "******";
            model.Password = "******";
            model.ConfirmPassword = "******";
            model.Email = "*****@*****.**";
            ActionResult actual;

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

            ControllerTestHelper.MimicValidation(model, target);

            using (mocks.Record())
            {
                Expect.Call(installerService.Install(model)).Return(InstallResults.InstallCompleted);
            }
            using (mocks.Playback())
            {
                actual = target.Index(model);
            }

            Helpers.ControllerTestHelper.TestForRedirection(actual,"Complete","Install","Install");
        }
        public void IndexTestWithUserNameAndEmailAndPasswordAndConfirmValidAndFailedResult()
        {
            InstallResults[] expecteds = { InstallResults.Unknown, InstallResults.ConfigFailed, InstallResults.DBConnectionFailed, InstallResults.DBInstallFailed };

            foreach (InstallResults it in expecteds)
            {
                MockRepository mocks = new MockRepository();

                IInstallerService installerService = mocks.StrictMock<IInstallerService>();
                InstallController target = new InstallController(installerService);

                InstallViewModel model = mocks.StrictMock<InstallViewModel>();
                model.UserName = "******";
                model.Password = "******";
                model.ConfirmPassword = "******";
                model.Email = "*****@*****.**";
                ActionResult actual;

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

                ControllerTestHelper.MimicValidation(model, target);

                using (mocks.Record())
                {
                    Expect.Call(installerService.Install(model)).Return(it);
                }
                using (mocks.Playback())
                {
                    actual = target.Index(model);
                }

                ViewResult actualTyped = Helpers.ControllerTestHelper.TestForEmptyViewNotModel(actual, target, typeof(InstallViewModel), 1);
                Assert.IsTrue(actualTyped.ViewData.ModelState.ContainsKey("")); //Master error
            }
        }
        public void IndexTestWithUpdateNeededStatus()
        {
            InstallController target = null;
            // Arrange
            MockRepository mocks = new MockRepository();
            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            ActionResult actual;

            using (mocks.Record())
            {
                Expect.Call(installerService.GetInstallStatus(SymNetInfo.Instance)).Return(InstallStatus.UpdateNeeded);
            }

            try
            {
                target = new InstallController(installerService);
                using (mocks.Playback())
                {
                    actual = target.Index();
                }

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

            ControllerTestHelper.TestForRedirection(actual, "Index", "Update", "Install");
        }
        public void IndexTestWithReadyToInstallStatus()
        {
            InstallController target = null;
            // Arrange
            MockRepository mocks = new MockRepository();
            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            ActionResult actual;

            using (mocks.Record())
            {
                Expect.Call(installerService.GetInstallStatus(SymNetInfo.Instance)).Return(InstallStatus.ReadyToInstall);
            }

            try
            {
                target = new InstallController(installerService);
                using (mocks.Playback())
                {
                    actual = target.Index();
                }
                Helpers.ControllerTestHelper.TestForEmptyViewAndModel(actual, target);
            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }
        }
        public void IndexTestWithNullModel()
        {
            MockRepository mocks = new MockRepository();

            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            InstallController target = new InstallController(installerService);

            InstallViewModel model = null;

            ActionResult actual;

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

            ControllerTestHelper.MimicValidation(model, target);

            using (mocks.Record())
            {

            }
            using (mocks.Playback())
            {
                actual = target.Index(model);
            }
            Helpers.ControllerTestHelper.TestForEmptyViewAndModel(actual, target);
        }