Пример #1
0
        private static void TestExpectedUserPermissionWithUserInLeadImplementingOrg(Person user,
                                                                                    Project project,
                                                                                    IFirmaBaseFeatureWithContext <Project> projectCheckingFeature,
                                                                                    Organization optionalOrganizationToMakeUserTemporaryMemberOf,
                                                                                    bool expectedPermission)
        {
            var originalUserOrg   = user.Organization;
            var originalUserOrgID = user.OrganizationID;

            // Make sure the user WAS NOT already a member of this org. That would indicate some confusion or misuse in the test setup.
            if (optionalOrganizationToMakeUserTemporaryMemberOf != null)
            {
                MakeOrganizationTheOnlyAndTheLeadImplementingOrganization(project, optionalOrganizationToMakeUserTemporaryMemberOf);
                Assert.That(user.OrganizationID != optionalOrganizationToMakeUserTemporaryMemberOf.OrganizationID);
                user.Organization   = optionalOrganizationToMakeUserTemporaryMemberOf;
                user.OrganizationID = optionalOrganizationToMakeUserTemporaryMemberOf.OrganizationID;
            }

            // Temp fake Session
            var tempFirmaSession = new FirmaSession(HttpRequestStorage.DatabaseEntities, user);

            Assert.That(projectCheckingFeature.HasPermission(tempFirmaSession, project).HasPermission == expectedPermission);
            project.ProjectOrganizations.Clear();
            user.Organization   = originalUserOrg;
            user.OrganizationID = originalUserOrgID;
        }
Пример #2
0
        private static void TestExpectedUserPermission(Person user, Project project, IFirmaBaseFeatureWithContext <Project> projectCheckingFeature, bool expectedPermission)
        {
            // Hack - fudge up a fake Session
            var tmpFirmaSession = TestFramework.TestFirmaSession.Create();

            // Normally we don't allow deliberate setting of null Person in constructor, so we need to work around this in test context.
            tmpFirmaSession.Person = user;
            Assert.That(projectCheckingFeature.HasPermission(tmpFirmaSession, project).HasPermission == expectedPermission);
        }
Пример #3
0
 public FirmaFeatureForProject(IFirmaBaseFeatureWithContext <Project> firmaFeatureWithContext) : base(firmaFeatureWithContext)
 {
 }
Пример #4
0
        private static void TestExpectedUserPermissionWithUserAsPrimaryContactForImplementingOrg(Person user,
                                                                                                 Project project,
                                                                                                 IFirmaBaseFeatureWithContext <Project> projectCheckingFeature,
                                                                                                 Organization orgUserShouldBeMemberOf,
                                                                                                 Organization organizationToMakeUserTemporaryPrimaryContactOfImplementingOrg,
                                                                                                 bool expectedPermission)
        {
            // We deliberately put user in a DIFFERENT org, so make user these aren't the same org
            Assert.That(orgUserShouldBeMemberOf.OrganizationID != organizationToMakeUserTemporaryPrimaryContactOfImplementingOrg.OrganizationID);
            var originalUserOrg   = user.Organization;
            var originalUserOrgID = user.OrganizationID;

            user.Organization   = orgUserShouldBeMemberOf;
            user.OrganizationID = orgUserShouldBeMemberOf.OrganizationID;

            // Make sure the user WAS NOT already primary contact. That would indicate confusion or misuse.
            Assert.That(user.OrganizationID != organizationToMakeUserTemporaryPrimaryContactOfImplementingOrg.OrganizationID);
            Assert.That(project.GetPrimaryContact() == null);

            organizationToMakeUserTemporaryPrimaryContactOfImplementingOrg.PrimaryContactPerson   = user;
            organizationToMakeUserTemporaryPrimaryContactOfImplementingOrg.PrimaryContactPersonID = user.PersonID;

            // Temp fake Session
            var tempFirmaSession = new FirmaSession(HttpRequestStorage.DatabaseEntities, user);

            Assert.That(projectCheckingFeature.HasPermission(tempFirmaSession, project).HasPermission == expectedPermission);

            user.Organization   = originalUserOrg;
            user.OrganizationID = originalUserOrgID;
        }
Пример #5
0
 private static void TestExpectedUserPermission(FirmaSession firmaSession, Project project, IFirmaBaseFeatureWithContext <Project> projectCheckingFeature, bool expectedPermission)
 {
     Assert.That(projectCheckingFeature.HasPermission(firmaSession, project).HasPermission == expectedPermission);
 }
 public FirmaFeatureWithContextImpl(IFirmaBaseFeatureWithContext <T> firmaFeatureWithContext)
 {
     _firmaFeatureWithContext = firmaFeatureWithContext;
 }