public void GivenUserHasNoRoles_WhenGrantAccess_ThenThrowException()
        {
            ManageCustomFieldPermission target = new ManageCustomFieldPermission(new Student());
            EducationSecurityPrincipal  user   = CreateUserWithNoRoles();

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

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

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndNotAssociatedToStudentSchool_WhenGrantAccess_ThenThrowException()
        {
            ManageCustomFieldPermission target = new ManageCustomFieldPermission(new Student {
                School = Data.Schools[0]
            });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(new List <School>());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndNotAssociatedToServiceOffering_WhenGrantAccess_ThenThrowException()
        {
            ManageCustomFieldPermission target = new ManageCustomFieldPermission(new Student
            {
                School = new School(),
                StudentAssignedOfferings = new List<StudentAssignedOffering>
                {
                    new StudentAssignedOffering
                    {
                        ServiceOffering = new ServiceOffering { Provider = Data.Providers[0] }
                    }
                }
            });
            EducationSecurityPrincipal user = CreateProviderUser(new List<Provider>());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsProvider_AndNotAssociatedToServiceOffering_WhenGrantAccess_ThenThrowException()
        {
            ManageCustomFieldPermission target = new ManageCustomFieldPermission(new Student
            {
                School = new School(),
                StudentAssignedOfferings = new List <StudentAssignedOffering>
                {
                    new StudentAssignedOffering
                    {
                        ServiceOffering = new ServiceOffering {
                            Provider = Data.Providers[0]
                        }
                    }
                }
            });
            EducationSecurityPrincipal user = CreateProviderUser(new List <Provider>());

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsSiteCoordinator_AndNotAssociatedToStudentSchool_WhenGrantAccess_ThenThrowException()
        {
            ManageCustomFieldPermission target = new ManageCustomFieldPermission(new Student { School = Data.Schools[0] });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(new List<School>());

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

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