示例#1
0
        public void Home_Organization_Finds_all_Organization_Data()
        {
            //Arrange
            VolunteerProject project1     = GetAProject("Project one of SuperOrg", "Fishing");
            VolunteerProject project2     = GetAProject("Project two if Super rg", "cooking");
            Organization     organization = GetAOrganization("SuperOrg", "*****@*****.**");

            project1.Owner  = organization;
            project2.Owner  = organization;
            organization.Id = 1;

            MocModelRepository repository = new MocModelRepository();

            repository.CreateOrganization(organization);
            repository.CreateProject(project1);
            repository.CreateProject(project2);

            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

            //Act
            var result = controller.Organization(organization.Id) as ViewResult;

            //Assert
            var model = (Organization)result.ViewData.Model;

            Assert.AreEqual(organization, model);
        }
示例#2
0
        public void Home_Index_Not_Logged_In_With_Projects_displays()
        {
            // Arrange
            MocModelRepository repository = new MocModelRepository();
            VolunteerProject   project    = GetAProject();

            repository.CreateProject(project);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

            // Act
            ViewResult result         = controller.Index() as ViewResult;
            var        suggestionList = (IEnumerable <VolunteerProject>)result.ViewBag.Suggestions;

            // Assert
            CollectionAssert.Contains(suggestionList.ToList(), project);
        }
示例#3
0
        public void Admin_Organizations_All_Added()
        {
            //Arrange
            MocModelRepository repository = new MocModelRepository();
            //Organization orgnaization1 = Utility.GetAnOrganization("Organization 1 - Vi har kager", "*****@*****.**");
            //Organization orgnaization2 = Utility.GetAnOrganization("organization 2 - vi har ikke kager", "*****@*****.**");
            //repository.CreateOrganization(orgnaization1);
            //repository.CreateOrganization(orgnaization2);
            AdminController controller = GetAdminController(repository, new MocWebSecurity(false));

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

            //Assert
            //var model = (IEnumerable<Organization>)result.ViewData.Model;
            //CollectionAssert.Contains(model.ToList(), orgnaization1);
            //CollectionAssert.Contains(model.ToList(), orgnaization2);
        }
示例#4
0
        public void Home_Volunteers_Return_VolunteerList_When_They_Exsist()
        {
            //Arrange
            MocModelRepository repository = new MocModelRepository();
            Volunteer          volunteer1 = GetAVolunteer("bent");
            Volunteer          volunteer2 = GetAVolunteer("ole");

            repository.CreateVolunteer(volunteer1);
            repository.CreateVolunteer(volunteer2);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

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

            //Assert
            var model = (IEnumerable <Volunteer>)result.ViewData.Model;

            CollectionAssert.Contains(model.ToList(), volunteer1);
            CollectionAssert.Contains(model.ToList(), volunteer2);
        }
示例#5
0
        public void Home_Organizations_Returns_OrganizationList_when_they_exist()
        {
            //Arrange
            MocModelRepository repository    = new MocModelRepository();
            Organization       orgnaization1 = GetAOrganization("Organization 1 - Vi har kager", "*****@*****.**");
            Organization       orgnaization2 = GetAOrganization("organization 2 - vi har ikke kager", "*****@*****.**");

            repository.CreateOrganization(orgnaization1);
            repository.CreateOrganization(orgnaization2);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

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

            //Assert
            var model = (IEnumerable <Organization>)result.ViewData.Model;

            CollectionAssert.Contains(model.ToList(), orgnaization1);
            CollectionAssert.Contains(model.ToList(), orgnaization2);
        }
示例#6
0
        public void Home_Projects_With_Projects()
        {
            // Arrange
            MocModelRepository repository = new MocModelRepository();
            VolunteerProject   project    = GetAProject("Some Project", "Testing testing");
            VolunteerProject   project2   = GetAProject("Another Project", "Just a test");

            repository.CreateProject(project);
            repository.CreateProject(project2);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

            // Act
            ViewResult result = controller.Projects() as ViewResult;

            // Assert
            var model = (IEnumerable <VolunteerProject>)result.ViewData.Model;

            CollectionAssert.Contains(model.ToList(), project);
            CollectionAssert.Contains(model.ToList(), project2);
        }
示例#7
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);
        }
示例#8
0
        public void Home_Volunteer_Return_Volunteer()
        {
            //Arrange
            Volunteer          volunteer  = GetAVolunteer("bent");
            VolunteerProject   project    = GetAProject("kage", "chokolade");
            Invite             invite     = new Invite(volunteer, project);
            MocModelRepository repository = new MocModelRepository();

            volunteer.ID = 1;
            repository.CreateVolunteer(volunteer);
            repository.CreateProject(project);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

            //Act
            var result = controller.Volunteer(volunteer.ID) as ViewResult;

            //Assert
            var model = (Volunteer)result.ViewData.Model;

            Assert.AreEqual(volunteer, model);
        }
示例#9
0
        public void Home_Project_Finds_all_Project_data()
        {
            //Arrange
            VolunteerProject project      = GetAProject("The Project", "Should have a lot of stuff");
            Organization     organization = GetAOrganization("Fisher", "*****@*****.**");

            project.Owner = organization;
            project.Id    = 1;
            MocModelRepository repository = new MocModelRepository();

            repository.CreateOrganization(organization);
            repository.CreateProject(project);
            HomeController controller = GetHomeController(repository, new MocWebSecurity(false));

            //Act
            ViewResult result = controller.Project(1) as ViewResult;

            //Assert
            var model = (VolunteerProject)result.ViewData.Model;

            Assert.AreEqual(project, model);//Uses reference equals beware!
        }
示例#10
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);
        }
示例#11
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");
        }