예제 #1
0
        public void Can_Set_Document_As_Not_Visible_To_Members()
        {
            // Setup
            IProcess <OrgMemberDocVisibilityByOrgAdminParams, GeneralSuccessResultViewModel> process = new OrganizationDocumentProcesses(_context);

            var org  = new Organization();
            var user = new User {
                Organization = org, IsOrganizationAdmin = true
            };
            var doc = new OfficialDocument {
                MeantForMembers = true
            };

            org.MemberOfficialDocuments.Add(doc);

            _context.Organizations.Add(org);
            _context.Users.Add(user);
            _context.OfficialDocuments.Add(doc);
            _context.SaveChanges();

            // Act
            var result = process.Execute(new OrgMemberDocVisibilityByOrgAdminParams
            {
                OfficialDocumentId = doc.Id,
                RequestingUserId   = user.Id,
                ShowToMembers      = false
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.WasSuccessful, "Process did not return a successful result");
            Assert.AreEqual(0, org.MemberOfficialDocuments.Count, "Organization had an incorrect number of member documents");
        }
예제 #2
0
        public OfficialDocument clone()
        {
            OfficialDocument far = null;

            try
            {
                far = (OfficialDocument)MemberwiseClone();
            }
            catch (Exception e)
            {
                Console.WriteLine("不支持复制");
            }
            return(far);
        }
예제 #3
0
        public OfficialDocument clone()
        {
            OfficialDocument srs = null;

            try
            {
                srs = (OfficialDocument)MemberwiseClone();
            }
            catch (Exception e)
            {
                Console.WriteLine("不可复制");
            }
            return(srs);
        }
예제 #4
0
        public void Throws_Exception_When_User_Not_Organization_Admin()
        {
            // Setup
            IProcess <OrgMemberDocVisibilityByOrgAdminParams, GeneralSuccessResultViewModel> process = new OrganizationDocumentProcesses(_context);

            var org  = new Organization();
            var user = new User {
                Organization = org, IsOrganizationAdmin = false
            };
            var doc = new OfficialDocument {
                MeantForMembers = true
            };

            org.MemberOfficialDocuments.Add(doc);

            _context.Users.Add(user);
            _context.OfficialDocuments.Add(doc);
            _context.SaveChanges();

            // Act
            try
            {
                process.Execute(new OrgMemberDocVisibilityByOrgAdminParams
                {
                    OfficialDocumentId = doc.Id,
                    RequestingUserId   = user.Id,
                    ShowToMembers      = false
                });
                Assert.Fail("No exception was thrown");
            }

            // Verify
            catch (UserNotAuthorizedForEntityException ex)
            {
                Assert.AreEqual(user.Id, ex.UserId, "Exception's user id value was not correct");
                Assert.AreEqual(user.Organization.Id, ex.IdValue, "Exception's entity id value was not correct");
                Assert.AreEqual(typeof(Organization), ex.EntityType, "Exception's entity type value was not correct");
            }
        }
        public void Can_Get_List_Of_Documents_Visible_To_User()
        {
            // Setup
            var doc1 = new OfficialDocument {
                MeantForMembers = true
            };
            var doc2 = new OfficialDocument {
                MeantForMembers = true
            };
            var doc3 = new OfficialDocument {
                MeantForMembers = true
            };
            var org  = new Organization();
            var user = new User {
                Organization = org
            };

            org.MemberOfficialDocuments.Add(doc1);
            org.MemberOfficialDocuments.Add(doc3);
            _context.Users.Add(user);
            _context.SaveChanges();

            IProcess <ByUserIdParams, VisibleOrgOfficialDocListForUserViewModel> process =
                new OrganizationDocumentProcesses(_context);

            // Act
            VisibleOrgOfficialDocListForUserViewModel result = process.Execute(new ByUserIdParams {
                UserId = user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Process result is null");
            Assert.AreEqual(2, result.UserVisibleDocuments.Count, "Document list contained an incorrect number of elements");
            Assert.IsTrue(result.UserVisibleDocuments.Contains(doc1), "Document list did not contain doc1");
            Assert.IsTrue(result.UserVisibleDocuments.Contains(doc3), "Document list did not contain doc3");
        }
예제 #6
0
 public void addOfficeDocument(string key, OfficialDocument doc)
 {
     ht.Add(key, doc);
 }