public void GivenUserIsProvider_AndUserApprovedNoProviders_AndStudentHasCustomDataNotAssociatedWithUser_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { CustomFieldValues = Data.CustomFieldValues });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Where(p => p != Data.StudentAssignedOfferings.First().ServiceOffering.Provider).ToList());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndStudentApprovedNoProviders_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal user = CreateProviderUser(new List<Provider>());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserHasNoRoles_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal  user   = CreateUserWithNoRoles();

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserRoleIsUnknown_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(Data.Students[0]);
            EducationSecurityPrincipal  user   = CreateUserWithUnknownRole();

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndSiteCoordinatorAssignedNoSchools_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal  user   = CreateSiteCoordinatorUser(new List <School>());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserHasNoRoles_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal user = CreateUserWithNoRoles();

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndStudentApprovedNoProviders_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal  user   = CreateProviderUser(new List <Provider>());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedProvidersDifferentThanStudentApproves_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                ApprovedProviders = Data.Providers.Take(1).ToList()
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Skip(1).ToList());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProviders_AndStudentAssignedOffering_AndStudentApprovesNoProviders_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                StudentAssignedOfferings = Data.StudentAssignedOfferings.Take(1).ToList()
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Where(p => p != Data.StudentAssignedOfferings.First().ServiceOffering.Provider).ToList());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndSiteCoordinatorAssignedSchoolsDifferentThanStudent_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                School = Data.Schools.First()
            });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(Data.Schools.Skip(1).ToList());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserApprovedNoProviders_AndStudentHasCustomDataNotAssociatedWithUser_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                CustomFieldValues = Data.CustomFieldValues
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Where(p => p != Data.StudentAssignedOfferings.First().ServiceOffering.Provider).ToList());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProviders_AndStudentApprovedAllProviders_AndStudentAssignedNoOfferings_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                ApprovedProviders = Data.Providers
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers);

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedProvidersDifferentThanApprovedByStudent_AndStudentAssignedOfferingAssociatedWithUser_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                ApprovedProviders = Data.Providers.Take(1).ToList(), StudentAssignedOfferings = Data.StudentAssignedOfferings.Where(s => s.ServiceOffering.Provider != Data.Providers.First()).ToList()
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Skip(1).ToList());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProvidersAndStudentApprovedAllProviders_AndStudentAssignedInactiveOfferings_WhenGrantAccess_ThenThrowException()
        {
            Data.StudentAssignedOfferings[0].IsActive = false;
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student {
                ApprovedProviders = Data.Providers, StudentAssignedOfferings = Data.StudentAssignedOfferings.Take(1).ToList()
            });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers);

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProvidersAndStudentApprovedAllProviders_AndStudentAssignedInactiveOfferings_WhenGrantAccess_ThenThrowException()
        {
            Data.StudentAssignedOfferings[0].IsActive = false;
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { ApprovedProviders = Data.Providers, StudentAssignedOfferings = Data.StudentAssignedOfferings.Take(1).ToList() });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers);

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProviders_AndStudentAssignedOffering_AndStudentApprovesNoProviders_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { StudentAssignedOfferings = Data.StudentAssignedOfferings.Take(1).ToList() });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Where(p => p != Data.StudentAssignedOfferings.First().ServiceOffering.Provider).ToList());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedProvidersDifferentThanApprovedByStudent_AndStudentAssignedOfferingAssociatedWithUser_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { ApprovedProviders = Data.Providers.Take(1).ToList(), StudentAssignedOfferings = Data.StudentAssignedOfferings.Where(s => s.ServiceOffering.Provider != Data.Providers.First()).ToList() });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Skip(1).ToList());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedProvidersDifferentThanStudentApproves_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { ApprovedProviders = Data.Providers.Take(1).ToList() });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers.Skip(1).ToList());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndUserAssignedAllProviders_AndStudentApprovedAllProviders_AndStudentIsOptedOut_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { ApprovedProviders = Data.Providers, HasParentalOptOut = true });
            EducationSecurityPrincipal user = CreateProviderUser(Data.Providers);

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndSiteCoordinatorAssignedNoSchools_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student());
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(new List<School>());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndSiteCoordinatorAssignedSchoolsDifferentThanStudent_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(new Student { School = Data.Schools.First() });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(Data.Schools.Skip(1).ToList());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserRoleIsUnknown_WhenGrantAccess_ThenThrowException()
        {
            ViewStudentDetailPermission target = new ViewStudentDetailPermission(Data.Students[0]);
            EducationSecurityPrincipal user = CreateUserWithUnknownRole();

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }