Esempio n. 1
0
        public void GivenAspxErrorPath_WhenNotFound_ThenViewModelIsAspxErrorPath()
        {
            string     expected = "apples/3";
            ViewResult result   = Target.NotFound(expected);

            result.AssertGetViewModel(expected);
        }
Esempio n. 2
0
        public void GivenStudentWithSchool_WhenGettingStudentDetails_ThenViewModelContainsSchoolName()
        {
            ViewResult         result = Target.Details(1) as ViewResult;
            StudentDetailModel actual = result.AssertGetViewModel <StudentDetailModel>();

            Assert.IsNotNull(actual.SchoolName);
        }
Esempio n. 3
0
        public void GivenStudentWithClassesAndTeachers_WhenGettingStudentDetails_ThenViewModelContainsClassesWithTeachers()
        {
            ViewResult         result = Target.Details(1) as ViewResult;
            StudentDetailModel actual = result.AssertGetViewModel <StudentDetailModel>();

            Assert.IsTrue(actual.Classes.Any());
            Assert.IsTrue(actual.Classes.All(c => c.Teacher != null));
        }
Esempio n. 4
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. 5
0
        public void GivenUserHasNoRoles_WhenIndex_ThenShowAddProviderFalse()
        {
            ViewResult result = Target.Index();

            PartnerListOptionsModel actual = result.AssertGetViewModel <PartnerListOptionsModel>();

            Assert.IsFalse(actual.ShowAddProvider);
        }
Esempio n. 6
0
        public void GivenWhitespaceAspxErrorPath_WhenNotFound_ThenViewModelIsRawUrl()
        {
            string expected = "oranges/4";

            MockHttpContext.Request.Expect(m => m.RawUrl).Return(expected);
            ViewResult result = Target.NotFound("       \r\n");

            result.AssertGetViewModel(expected);
        }
Esempio n. 7
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());
        }
        public void GivenLogicManagerGeneratesViewModel_WhenGetManageView_ThenViewContainsViewModel()
        {
            StudentApprovalListOptionsModel expected = new StudentApprovalListOptionsModel();

            MockLogicManager.Expect(m => m.GenerateApprovalListOptionsViewModel()).Return(expected);

            ViewResult actual = Target.Index();

            actual.AssertGetViewModel(expected);
        }
        public void WhenIViewLogin_ThenViewModelNamespaceIsFromConfiguration()
        {
            string expected = CloudConfigurationManager.GetSetting("AcsNamespace");

            ViewResult result = Target.Login();

            LoginModel actual = result.AssertGetViewModel <LoginModel>();

            Assert.AreEqual(expected, actual.Namespace);
        }
        public void WhenIViewLogin_ThenViewModelRealmIsApplicationUrl()
        {
            string expected = AuthenticationUtility.GetApplicationUri(MockHttpContext.Request);

            ViewResult result = Target.Login();

            LoginModel actual = result.AssertGetViewModel <LoginModel>();

            Assert.AreEqual(expected, actual.Realm);
        }
        public void WhenManageIsCalled_ThenAViewWithAListOfCategoriesIsReturned()
        {
            ServiceTypeListOptionsModel expected = new ServiceTypeListOptionsModel();

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

            ViewResult result = Target.Index();

            result.AssertGetViewModel(expected);
        }
        public void GivenViewModelIsCreated_WhenManageIsCalled_ThenViewModelMatchesCreated()
        {
            ServiceOfferingListOptionsModel expected = new ServiceOfferingListOptionsModel();

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

            ViewResult result = Target.Index();

            result.AssertGetViewModel(expected);
        }
Esempio n. 13
0
        public void GivenLogicManagerReturnsViewModel_WhenIndex_ThenViewResultContainsModel()
        {
            EulaModel expected = new EulaModel();

            MockLogicManager.Expect(m => m.GeneratePromptViewModel()).Return(expected);

            ViewResult result = Target.Index();

            result.AssertGetViewModel(expected);
        }
        public void GivenGuid_WhenIConfirmEmail_ThenViewHasViewModel()
        {
            ConfirmEmailModel expected = new ConfirmEmailModel();
            Guid expectedIdentifier    = Guid.NewGuid();

            MockAccountManager.Expect(m => m.GenerateConfirmEmailViewModel(expectedIdentifier)).Return(expected);

            ViewResult actual = Target.ConfirmEmail(expectedIdentifier);

            actual.AssertGetViewModel(expected);
        }
        public void GivenUser_WhenIViewProfile_ThenViewHasViewModel()
        {
            UserModel expected = new UserModel();
            EducationSecurityPrincipal expectedUser = new EducationSecurityPrincipal(new EducationSecurityIdentity(Identity, TestUser));

            MockHttpContext.Expect(m => m.User).Return(expectedUser);
            MockAccountManager.Expect(m => m.GenerateUserProfileViewModel(expectedUser)).Return(expected);

            ViewResult actual = Target.UserProfile();

            actual.AssertGetViewModel(expected);
        }
        public void GivenUserHasFavorites_WhenIManage_ThenFavoritesAreLoaded()
        {
            ViewResult result = Target.Index();

            ServiceOfferingListOptionsModel viewModel = result.AssertGetViewModel <ServiceOfferingListOptionsModel>();
            List <ServiceOffering>          actual    = viewModel.Favorites.ToList();

            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Count);
            Assert.AreEqual("Big Brothers, Big Sisters", actual[0].Provider.Name);
            Assert.AreEqual("Provide College Access", actual[0].ServiceType.Name);
        }
Esempio n. 17
0
        public void GivenUserIsSiteCoordinator_WhenIndex_ThenShowAddProviderTrue()
        {
            User.Identity.User.UserRoles.Add(new UserRole {
                Role = new Role {
                    Name = SecurityRoles.SiteCoordinator
                }
            });

            ViewResult result = Target.Index();

            PartnerListOptionsModel actual = result.AssertGetViewModel <PartnerListOptionsModel>();

            Assert.IsTrue(actual.ShowAddProvider);
        }
        public void WhenManageIsCalled_ThenAViewWithAListOfCategoriesIsReturned()
        {
            var expected = new List <string>
            {
                "Basic Needs", "Consumer Services", "Criminal Justice and Legal Services", "Education", "Environmental Quality",
                "Health Care", "Income Support and Employment", "Individual and Family Life", "Mental Health Care and Counseling",
                "Organizational/Community Services", "Support Groups", "Target Populations", "Test Category,"
            };

            ViewResult result = Target.Index();

            ServiceTypeListOptionsModel model = result.AssertGetViewModel <ServiceTypeListOptionsModel>();

            CollectionAssert.AreEquivalent(expected, model.CategoryFilterList.ToList());
        }
        public void WhenUploadFile_ThenFileProcessorConsumesFile_AndResultingDataTableIsImported_AndResultingModelReturnedInViewResult()
        {
            ServiceUploadModel expected      = new ServiceUploadModel();
            DataTable          expectedTable = new DataTable();
            var path = Path.Combine(UploadTemplateFolderPath, ServiceAttendanceController.TemplateFile);
            var file = MockRepository.GenerateStub <UploadExcelFileModel>();

            file.File = MockRepository.GenerateStub <HttpPostedFileBase>();
            file.File.Expect(f => f.ContentLength).Return(1);
            MockFileProcessor.Expect(m => m.ConsumeFile(file)).Return(expectedTable);
            MockFileProcessor.Expect(m => m.Import(User, path, expectedTable)).Return(expected);;

            ViewResult actual = Target.FileUpload(file) as ViewResult;

            actual.AssertGetViewModel(expected);
        }
Esempio n. 20
0
        public void GivenViewModelIsGenerated_AndAReturnUrl_WhenIScheduleServiceOffering_ThenViewModelHasReturnUrl()
        {
            var students = new int[] { 1, 2 };

            MockLogicManager.Expect(m => m.GenerateScheduleOfferingViewModel(User, students)).Return(new ScheduleServiceOfferingListOptionsModel());
            string expected = "blahlsdkjfsdlfkjsdlkfjs";

            Target.TempData["ScheduleOfferingIds"]       = students;
            Target.TempData["ScheduleOfferingReturnUrl"] = expected;

            ViewResult result = Target.ScheduleOffering() as ViewResult;

            ScheduleServiceOfferingListOptionsModel actual = result.AssertGetViewModel <ScheduleServiceOfferingListOptionsModel>();

            Assert.AreEqual(expected, actual.ReturnUrl);
        }
        public void GivenAClaimsIdentityExists_AndUserIsAuthenticated_AndUserExists_AndUserDoesNotHaveRole_WhenIAuthorize_ThenViewResultDataContainsRoles()
        {
            User expectedUser = new User {
                UserKey = "whatever", UserRoles = new List <UserRole> {
                    new UserRole {
                        Role = new Role {
                            Name = "supervisor"
                        }
                    }
                }
            };
            AuthorizationContext authorizationContext = CreateAuthorizationContext(false, expectedUser.UserKey);

            authorizationContext.HttpContext.Request.Expect(m => m.FilePath).Return("hsdjkfhdkjhsfkjhdkjsf");
            MockAccountManager.Expect(m => m.EnsureUserEntity(authorizationContext.HttpContext.User.Identity as System.Security.Claims.ClaimsIdentity)).Return(expectedUser);

            Target.Roles = "admin";
            Target.OnAuthorization(authorizationContext);

            ViewResult           result    = authorizationContext.Result as ViewResult;
            IEnumerable <string> viewModel = result.AssertGetViewModel <IEnumerable <string> >();

            CollectionAssert.AreEqual(expectedUser.UserRoles.Select(m => m.Role.Name).ToList(), viewModel.ToList());
        }
Esempio n. 22
0
        public void WhenIndex_ThenListOptionsViewModelInResult()
        {
            ViewResult result = Target.Index();

            result.AssertGetViewModel <PartnerListOptionsModel>();
        }