Exemplo n.º 1
0
        public void Admin_Index_Not_Associated()
        {
            //Arrange
            Admin admin = Utility.GetAnAdmin("bent");

            admin.Association = null;
            MocWebSecurity     security   = new MocWebSecurity(true);
            MocModelRepository repository = new MocModelRepository();

            repository.CreateAdmin(admin);
            security.Username = "******";
            AdminController controller = GetAdminController(repository, security);

            //Act
            var result = controller.Index() as ViewResult;

            //Assert
            Assert.AreEqual(true, result.ViewBag.Authenticated);
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 2
0
        public void Admin_Index_IS_Associated()
        {
            //Arrange
            Admin        admin        = Utility.GetAnAdmin("bent");
            Organization organization = Utility.GetAnOrganization("Fisker", "*****@*****.**");

            admin.Association = organization;
            MocWebSecurity     security   = new MocWebSecurity(true);
            MocModelRepository repository = new MocModelRepository();

            repository.CreateAdmin(admin);
            repository.CreateOrganization(organization);
            security.Username = "******";
            AdminController controller = GetAdminController(repository, security);

            //Act
            var result = controller.Index() as ViewResult;

            //Assert
            Assert.AreEqual(false, result.ViewBag.Authenticated);
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 3
0
        public void Home_Index_loggedIn_Volunteer_redirects_to_Volunteer_Index()
        {
            //Arrange
            MocWebSecurity auth = new MocWebSecurity(true);

            auth.Username = "******";
            MocModelRepository repository = new MocModelRepository();
            Volunteer          volunteer  = new Volunteer("SomeVolunteer");

            repository.CreateVolunteer(volunteer);
            HomeController controller = GetHomeController(repository, auth);

            //Act
            var result = controller.Index() as RedirectToRouteResult;

            //Assert
            if (result == null)
            {
                Assert.Fail("Should have redirected");
            }
            Assert.AreEqual(result.RouteValues["Controller"], "volunteer");
            Assert.AreEqual(result.RouteValues["Action"], "index");
        }