Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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
            }
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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();
                }
            }
        }
Ejemplo n.º 6
0
        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);
        }