Ejemplo n.º 1
0
        public void Register_FailedSave_ReturnsRedirect()
        {
            // arrange
            var accountController = new AccountController(
                new Mock<IFormsAuthenticationService>().Object,
                new Mock<IDataService<Volunteer>>().Object);

            accountController.ModelState.AddModelError("testRequired", "dummy required field missing");

            var fakeVolunteer = new Volunteer
                                    {
                                        FirstName = "Firstname",
                                        LastName = "LNameTest",
                                        Username = "******",
                                        Password = "******"
                                    };

            ActionResult result = accountController.Register(fakeVolunteer);

            Assert.IsInstanceOf<ViewResult>(result);

            var view = (ViewResult) result;

            Assert.IsInstanceOf<Volunteer>(view.Model);
        }
Ejemplo n.º 2
0
        public void Register_ReturnsView()
        {
            var accountController = new AccountController(
                new Mock<IFormsAuthenticationService>().Object,
                new Mock<IDataService<Volunteer>>().Object);

            ActionResult result = accountController.Register();

            Assert.IsInstanceOf<ViewResult>(result);
            var view = (ViewResult) result;
            Assert.IsNotNull(view.ViewData.Model);
            Assert.IsInstanceOf<Volunteer>(view.ViewData.Model);
        }
Ejemplo n.º 3
0
        public void Register_Save_ReturnsRedirect()
        {
            var fakeVolunteer = new Volunteer
                                    {
                                        FirstName = "Firstname",
                                        LastName = "LNameTest",
                                        Username = "******",
                                        Password = "******",
                                        PrimaryPhone = "3334445555",
                                        Email = "*****@*****.**"
                                    };

            var dataService = new Mock<IDataService<Volunteer>>();

            dataService.Setup(d => d.Insert(fakeVolunteer, It.IsAny<Guid>())).Verifiable("Save was not called.");

            var accountController = new AccountController(
                new Mock<IFormsAuthenticationService>().Object,
                dataService.Object);

            ActionResult result = accountController.Register(fakeVolunteer);

            dataService.VerifyAll();

            Assert.IsInstanceOf<RedirectToRouteResult>(result);
        }