Esempio n. 1
0
        public void GivenStudentsWithSchools_WhenGettingStudentFinder_ThenViewModelContainsSchoolFilterList_AndViewModelContainsGradeFilterList()
        {
            ViewResult result = Target.Index() as ViewResult;
            StudentListOptionsModel actual = result.AssertGetViewModel <StudentListOptionsModel>();

            Assert.IsTrue(actual.SchoolFilterList.Any());
            Assert.IsTrue(actual.GradeFilterList.Any());
        }
Esempio n. 2
0
 private void InitializeFilterLists(StudentListOptionsModel viewModel)
 {
     viewModel.GradeFilterList         = StudentRepository.Items.Select(g => g.Grade).Distinct().ToList();
     viewModel.SchoolFilterList        = LoadSchoolNameList();
     viewModel.PriorityFilterList      = PriorityRepository.Items.Select(p => p.Name).ToList();
     viewModel.RequestStatusFilterList = FulfillmentStatusRepository.Items.Select(f => f.Name).ToList();
     viewModel.ServiceTypeFilterList   = ServiceTypeRepository.Items.Where(s => s.IsActive).Select(t => t.Name).ToList();
     viewModel.SubjectFilterList       = SubjectRepository.Items.Select(s => s.Name).ToList();
 }
Esempio n. 3
0
        public void WhenStudentFinderActionIsCalled_ThenViewResultHasViewModel()
        {
            StudentListOptionsModel expected = new StudentListOptionsModel();

            MockLogicManager.Expect(m => m.GenerateListOptionsViewModel(User)).Return(expected);

            var result = Target.Index() as ViewResult;

            result.AssertGetViewModel(expected);
        }
Esempio n. 4
0
        public void GivenStudentsWithSchools_WhenGettingStudentFinder_ThenViewModelContainsServiceRequestFilterLists()
        {
            ViewResult result = Target.Index() as ViewResult;
            StudentListOptionsModel actual = result.AssertGetViewModel <StudentListOptionsModel>();

            Assert.IsTrue(actual.PriorityFilterList.Any());
            Assert.IsTrue(actual.RequestStatusFilterList.Any());
            Assert.IsTrue(actual.ServiceTypeFilterList.Any());
            Assert.IsTrue(actual.SubjectFilterList.Any());
        }
Esempio n. 5
0
        public StudentListOptionsModel GenerateListOptionsViewModel(EducationSecurityPrincipal user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var viewModel = new StudentListOptionsModel
            {
                IsProvider = !user.IsInRole(SecurityRoles.DataAdmin) && !user.IsInRole(SecurityRoles.SiteCoordinator) && user.IsInRole(SecurityRoles.Provider)
            };

            InitializeFilterLists(viewModel);
            return(viewModel);
        }
        public void WhenGenerateListOptionsViewModel_ThenViewModelHasFilterLists()
        {
            Func <Student, string> orderingFunction = (s => s.School.Name);
            var expected = new StudentListOptionsModel
            {
                GradeFilterList       = Repositories.MockStudentRepository.Items.Select(i => i.Grade).Distinct(),
                SchoolFilterList      = Repositories.MockStudentRepository.Items.OrderBy(orderingFunction, new NaturalSortComparer <string>()).Select(s => s.School.Name).Distinct(),
                PriorityFilterList    = Repositories.MockPriorityRepository.Items.Select(p => p.Name),
                ServiceTypeFilterList = Repositories.MockServiceTypeRepository.Items.Where(s => s.IsActive).Select(t => t.Name),
                SubjectFilterList     = Repositories.MockSubjectRepository.Items.Select(s => s.Name)
            };

            StudentListOptionsModel actual = Target.GenerateListOptionsViewModel(User);

            CollectionAssert.AreEqual(expected.GradeFilterList.ToList(), actual.GradeFilterList.ToList());
            CollectionAssert.AreEqual(expected.SchoolFilterList.ToList(), actual.SchoolFilterList.ToList());
            CollectionAssert.AreEqual(expected.PriorityFilterList.ToList(), actual.PriorityFilterList.ToList());
            CollectionAssert.AreEqual(expected.ServiceTypeFilterList.ToList(), actual.ServiceTypeFilterList.ToList());
            CollectionAssert.AreEqual(expected.SubjectFilterList.ToList(), actual.SubjectFilterList.ToList());
        }