• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PersonBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PersonBuilder的典型用法代码示例。如果您正苦于以下问题:C# PersonBuilder类的具体用法?C# PersonBuilder怎么用?C# PersonBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PersonBuilder类属于命名空间,在下文中一共展示了PersonBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GivenPaymentApplication_WhenDeriving_ThenRequiredRelationsMustExist

        public void GivenPaymentApplication_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var billToContactMechanism = new EmailAddressBuilder(this.DatabaseSession).WithElectronicAddressString("[email protected]").Build();

            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            new CustomerRelationshipBuilder(this.DatabaseSession)
                .WithCustomer(customer)
                .WithInternalOrganisation(Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation)
                .Build();

            new SalesInvoiceBuilder(this.DatabaseSession)
                .WithBillToCustomer(customer)
                .WithBillToContactMechanism(billToContactMechanism)
                .WithSalesInvoiceType(new SalesInvoiceTypes(this.DatabaseSession).SalesInvoice)
                .WithSalesInvoiceItem(new SalesInvoiceItemBuilder(this.DatabaseSession)
                                        .WithProduct(new GoodBuilder(this.DatabaseSession).WithName("good").Build())
                                        .WithSalesInvoiceItemType(new SalesInvoiceItemTypes(this.DatabaseSession).ProductItem)
                                        .WithQuantity(1)
                                        .WithActualUnitPrice(100M)
                                        .Build())
                .Build();

            var builder = new PaymentApplicationBuilder(this.DatabaseSession);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithAmountApplied(0);
            builder.Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
开发者ID:Allors,项目名称:apps,代码行数:34,代码来源:PaymentApplicationTests.cs


示例2: Cache

        public void Cache()
        {
            var person = new PersonBuilder(this.Session).WithFirstName("John").Build();

            var stringTemplate = new StringTemplateBuilder(this.Session).WithBody(
            @"main(this) ::= <<
            Hello $this.FirstName$!
            >>").Build();

            for (var i = 0; i < NrOfRuns; i++)
            {
                var result = stringTemplate.Apply(new Dictionary<string, object> { { "this", person } });
                Assert.AreEqual("Hello John!", result);
            }

            stringTemplate.Body =
            @"main(this) ::= <<
            Hi $this.FirstName$!
            >>";

            this.Session.Derive();

            for (var i = 0; i < NrOfRuns; i++)
            {
                var result = stringTemplate.Apply(new Dictionary<string, object> { { "this", person } });
                Assert.AreEqual("Hi John!", result);
            }
        }
开发者ID:whesius,项目名称:allors,代码行数:28,代码来源:StringTemplateTests.cs


示例3: GivenCurrentUserIsKnown_WhenAccessingFaceToFaceCommunicationWithOwner_ThenOwnerSecurityTokenIsApplied

        public void GivenCurrentUserIsKnown_WhenAccessingFaceToFaceCommunicationWithOwner_ThenOwnerSecurityTokenIsApplied()
        {
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("user"), new string[0]);

            var user = new PersonBuilder(this.DatabaseSession).WithLastName("user").WithUserName("user").Build();

            var owner = new PersonBuilder(this.DatabaseSession).WithLastName("owner").Build();
            var participant1 = new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build();
            var participant2 = new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession)
                .WithOwner(owner)
                .WithSubject("subject")
                .WithParticipant(participant1)
                .WithParticipant(participant2)
                .WithActualStart(DateTime.UtcNow)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(2, communication.SecurityTokens.Count);
            Assert.Contains(Singleton.Instance(this.DatabaseSession).DefaultSecurityToken, communication.SecurityTokens);
            Assert.Contains(owner.OwnerSecurityToken, communication.SecurityTokens);
        }
开发者ID:Allors,项目名称:apps,代码行数:27,代码来源:FaceToFaceCommunicationTests.cs


示例4: GivenOrganisation_WhenCurrentUserIsContactForOrganisation_ThenCustomerPermissionsAreGranted

        public void GivenOrganisation_WhenCurrentUserIsContactForOrganisation_ThenCustomerPermissionsAreGranted()
        {
            var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation");
            var organisation = new OrganisationBuilder(this.DatabaseSession).WithName("organisation").Build();
            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("Customer").WithUserName("customer").Build();

            new CustomerRelationshipBuilder(this.DatabaseSession).WithCustomer(organisation).WithInternalOrganisation(internalOrganisation).Build();
            new OrganisationContactRelationshipBuilder(this.DatabaseSession).WithContact(customer).WithOrganisation(organisation).WithFromDate(DateTime.UtcNow).Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("customer", "Forms"), new string[0]);
            var acl = new AccessControlList(organisation, new Users(this.DatabaseSession).GetCurrentUser());

            Assert.IsTrue(acl.CanRead(Organisations.Meta.Name));
            Assert.IsTrue(acl.CanWrite(Organisations.Meta.Name));
            Assert.IsTrue(acl.CanRead(Organisations.Meta.LegalForm));
            Assert.IsTrue(acl.CanWrite(Organisations.Meta.LegalForm));
            Assert.IsTrue(acl.CanRead(Organisations.Meta.LogoImage));
            Assert.IsTrue(acl.CanWrite(Organisations.Meta.LogoImage));
            Assert.IsTrue(acl.CanRead(Organisations.Meta.Locale));
            Assert.IsTrue(acl.CanWrite(Organisations.Meta.Locale));

            Assert.IsFalse(acl.CanRead(Organisations.Meta.OwnerSecurityToken));
            Assert.IsFalse(acl.CanWrite(Organisations.Meta.OwnerSecurityToken));
        }
开发者ID:Allors,项目名称:apps,代码行数:27,代码来源:OrganisationTests.cs


示例5: GivenNextSalesRep_WhenEmploymentAndSalesRepRelationshipAreCreated_ThenSalesRepIsAddedToUserGroup

        public void GivenNextSalesRep_WhenEmploymentAndSalesRepRelationshipAreCreated_ThenSalesRepIsAddedToUserGroup()
        {
            var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation");
            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();

            var usergroups = internalOrganisation.UserGroupsWhereParty;
            usergroups.Filter.AddEquals(UserGroups.Meta.Parent, new Roles(this.DatabaseSession).Sales.UserGroupWhereRole);
            var salesRepUserGroup = usergroups.First;

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1, salesRepUserGroup.Members.Count);
            Assert.Contains(new Persons(this.DatabaseSession).FindBy(Persons.Meta.LastName, "salesRep"), salesRepUserGroup.Members);

            var salesrep2 = new PersonBuilder(this.DatabaseSession).WithLastName("salesRep2").WithUserName("salesRep2").Build();

            new EmploymentBuilder(this.DatabaseSession)
                .WithFromDate(DateTime.UtcNow)
                .WithEmployee(salesrep2)
                .WithEmployer(internalOrganisation)
                .Build();

            new SalesRepRelationshipBuilder(this.DatabaseSession)
                .WithFromDate(DateTime.UtcNow)
                .WithCustomer(customer)
                .WithSalesRepresentative(salesrep2)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(2, salesRepUserGroup.Members.Count);
            Assert.IsTrue(salesRepUserGroup.Members.Contains(salesrep2));
        }
开发者ID:Allors,项目名称:apps,代码行数:33,代码来源:SalesRepRelationshipTests.cs


示例6: GivenCustomerRelationshipBuilder_WhenBuild_ThenSubAccountNumerIsValidElevenTestNumber

        public void GivenCustomerRelationshipBuilder_WhenBuild_ThenSubAccountNumerIsValidElevenTestNumber()
        {
            var internalOrganisation = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation;
            internalOrganisation.SubAccountCounter.Value = 1000;

            this.DatabaseSession.Commit();

            var customer1 = new PersonBuilder(this.DatabaseSession).WithLastName("customer1").Build();
            var customerRelationship1 = new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(customer1).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1007, customerRelationship1.SubAccountNumber);

            var customer2 = new PersonBuilder(this.DatabaseSession).WithLastName("customer2").Build();
            var customerRelationship2 = new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(customer2).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1015, customerRelationship2.SubAccountNumber);

            var customer3 = new PersonBuilder(this.DatabaseSession).WithLastName("customer3").Build();
            var customerRelationship3 = new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(customer3).Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1023, customerRelationship3.SubAccountNumber);
        }
开发者ID:Allors,项目名称:apps,代码行数:28,代码来源:CustomerRelationshipTests.cs


示例7: GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations

        public void GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations()
        {
            var builder = new PersonBuilder(this.Session);
            builder.Build();

            Assert.IsFalse(this.Session.Derive().HasErrors);
        }
开发者ID:Allors,项目名称:demo,代码行数:7,代码来源:PersonTests.cs


示例8: GivenorganisationContactRelationship_WhenDeriving_ThenRequiredRelationsMustExist

        public void GivenorganisationContactRelationship_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var contact = new PersonBuilder(this.DatabaseSession).WithLastName("organisationContact").Build();
            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            this.InstantiateObjects(this.DatabaseSession);

            var builder = new OrganisationContactRelationshipBuilder(this.DatabaseSession);
            var relationship = builder.Build();

            this.DatabaseSession.Derive();
            Assert.IsTrue(relationship.Strategy.IsDeleted);

            this.DatabaseSession.Rollback();

            builder.WithContact(contact);
            relationship = builder.Build();

            this.DatabaseSession.Derive();
            Assert.IsTrue(relationship.Strategy.IsDeleted);

            this.DatabaseSession.Rollback();

            builder.WithOrganisation(new OrganisationBuilder(this.DatabaseSession).WithName("organisation").WithLocale(Singleton.Instance(this.DatabaseSession).DefaultLocale).Build());
            builder.Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
开发者ID:Allors,项目名称:apps,代码行数:29,代码来源:OrganisationContactRelationshipTests.cs


示例9: TestInvoices

        public void TestInvoices()
        {
            var departmentA = new DepartmentBuilder(this.Session).Build();
            var departmentB = new DepartmentBuilder(this.Session).Build();

            var accountantA = new PersonBuilder(this.Session).WithFirstName("Accountant").WithLastName("A").Build();
            var accountantB = new PersonBuilder(this.Session).WithFirstName("Accountant").WithLastName("B").Build();

            departmentA.AddAccountant(accountantA);
            departmentB.AddAccountant(accountantB);

            var invoiceA = new InvoiceBuilder(this.Session).Build();
            var invoiceB = new InvoiceBuilder(this.Session).Build();

            departmentA.AddInvoice(invoiceA);
            departmentB.AddInvoice(invoiceB);

            this.Session.Derive();

            // Accountant A
            var aclAccountatAInvoiceA = new AccessControlList(invoiceA, accountantA);
            var aclAccountatAInvoiceB = new AccessControlList(invoiceB, accountantA);

            aclAccountatAInvoiceA.CanWrite(Invoice.Meta.Total).ShouldBeTrue();
            aclAccountatAInvoiceB.CanWrite(Invoice.Meta.Total).ShouldBeFalse();

            // Accountant B
            var aclAccountatBInvoiceA = new AccessControlList(invoiceA, accountantB);
            var aclAccountatBInvoiceB = new AccessControlList(invoiceB, accountantB);

            aclAccountatBInvoiceA.CanWrite(Invoice.Meta.Total).ShouldBeFalse();
            aclAccountatBInvoiceB.CanWrite(Invoice.Meta.Total).ShouldBeTrue();
        }
开发者ID:Allors,项目名称:demo,代码行数:33,代码来源:AccountantTests.cs


示例10: TestEmployeesCanRead

        public void TestEmployeesCanRead()
        {
            var employeeRole = new Roles(this.Session).Employee;

            var employees = new UserGroupBuilder(this.Session)
                .WithName("Employees")
                .Build();

            var john = new PersonBuilder(this.Session).WithFirstName("John").WithLastName("Doe").Build();
            employees.AddMember(john);

            var invoice = new InvoiceBuilder(this.Session).Build();

            var singleton = Singleton.Instance(this.Session);
            var defaultSecurityToken = singleton.DefaultSecurityToken;

            var accessControl = new AccessControlBuilder(this.Session)
                .WithRole(employeeRole)
                .WithObject(defaultSecurityToken)
                .WithSubjectGroup(employees)
                .Build();

            var acl = new AccessControlList(invoice, john);

            acl.CanRead(Invoice.Meta.Total).ShouldBeTrue();
        }
开发者ID:Allors,项目名称:demo,代码行数:26,代码来源:AccountantTests.cs


示例11: Index

        //
        // GET: /Home/
        public ActionResult Index()
        {
            new PersonService("some").Process2().Process();

            var person = new PersonBuilder()
                .WithFirstName("dean")
                .WithFirstName("seb")
                .WithActiveLoans(10).Create();

            return View();
        }
开发者ID:KHProjects,项目名称:KH-Parker-Fox,代码行数:13,代码来源:HomeController.cs


示例12: WhenDeletingUserThenLoginShouldAlsoBeDeleted

        public void WhenDeletingUserThenLoginShouldAlsoBeDeleted()
        {
            var user = new PersonBuilder(this.Session).WithUserName("User").WithLastName("User").Build();
            var login = new LoginBuilder(this.Session).WithUser(user).WithProvider("MyProvider").WithKey("XXXYYYZZZ").Build();

            this.Session.Derive();

            user.Delete();

            this.Session.Derive();

            Assert.IsTrue(login.Strategy.IsDeleted);
        }
开发者ID:whesius,项目名称:allors,代码行数:13,代码来源:LoginTests.cs


示例13: GivenActiveCustomerRelationship_WhenDeriving_ThenInternalOrganisationCustomersContainsCustomer

        public void GivenActiveCustomerRelationship_WhenDeriving_ThenInternalOrganisationCustomersContainsCustomer()
        {
            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            var internalOrganisation = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation;

            new CustomerRelationshipBuilder(this.DatabaseSession)
                .WithCustomer(customer)
                .WithInternalOrganisation(internalOrganisation)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.Contains(customer, internalOrganisation.Customers);
        }
开发者ID:Allors,项目名称:apps,代码行数:14,代码来源:CustomerRelationshipTests.cs


示例14: GivenActiveEmployment_WhenDeriving_ThenInternalOrganisationEmployeesContainsEmployee

        public void GivenActiveEmployment_WhenDeriving_ThenInternalOrganisationEmployeesContainsEmployee()
        {
            var employee = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            var employer = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation;

            new EmploymentBuilder(this.DatabaseSession)
                .WithEmployee(employee)
                .WithEmployer(employer)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.Contains(employee, employer.Employees);
        }
开发者ID:Allors,项目名称:apps,代码行数:14,代码来源:CustomerRelationshipTests.cs


示例15: data_using_default_person_builder

        public data_using_default_person_builder()
        {
            _personBuilder = new PersonBuilder(DataContainer);
            _emailBuilder = new EmailBuilder(DataContainer);

            _builder = new Builder<MyPerson>()
                .With(x =>
                          {
                              var person = _personBuilder.Build();
                              var emails = _emailBuilder.WithPerson(person).Build(1, 3).ToArray();

                              x.Name = person.FullName;
                              x.Emails = emails.Select(e => e.Address);
                          });
        }
开发者ID:MrAntix,项目名称:Testing,代码行数:15,代码来源:data_using_default_person_builder.cs


示例16: CreateUser

        private void CreateUser(IdentityUser identityUser)
        {
            using (var session = this.Database.CreateSession())
            {
                var person = new PersonBuilder(session)
                    .WithUserName(identityUser.UserName)
                    .WithUserEmail(identityUser.Email)
                    .WithUserEmailConfirmed(identityUser.EmailConfirmed)
                    .WithUserPasswordHash(identityUser.PasswordHash)
                    .Build();

                session.Derive();
                identityUser.MapFrom(person);
                session.Commit();
            }
        }
开发者ID:whesius,项目名称:allors,代码行数:16,代码来源:UserStore.v.cs


示例17: GivenPaymentApplication_WhenDeriving_ThenAmountAppliedCannotBeLargerThenAmountReceived

        public void GivenPaymentApplication_WhenDeriving_ThenAmountAppliedCannotBeLargerThenAmountReceived()
        {
            var contactMechanism = new ContactMechanisms(this.DatabaseSession).Extent().First;

            var good = new GoodBuilder(this.DatabaseSession)
                .WithSku("10101")
                .WithVatRate(new VatRateBuilder(this.DatabaseSession).WithRate(0).Build())
                .WithName("good")
                .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized)
                .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
                .Build();

            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            new CustomerRelationshipBuilder(this.DatabaseSession)
                .WithCustomer(customer)
                .WithInternalOrganisation(Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation)
                .Build();

            var invoice = new SalesInvoiceBuilder(this.DatabaseSession)
                .WithBillToCustomer(customer)
                .WithBillToContactMechanism(contactMechanism)
                .WithSalesInvoiceItem(new SalesInvoiceItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantity(1).WithActualUnitPrice(1000M).WithSalesInvoiceItemType(new SalesInvoiceItemTypes(this.DatabaseSession).ProductItem).Build())
                .Build();

            this.DatabaseSession.Derive(true);

            var receipt = new ReceiptBuilder(this.DatabaseSession)
                .WithAmount(100)
                .WithEffectiveDate(DateTime.UtcNow)
                .Build();

            var paymentApplication = new PaymentApplicationBuilder(this.DatabaseSession)
                .WithAmountApplied(200)
                .WithInvoiceItem(invoice.InvoiceItems[0])
                .Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            receipt.AddPaymentApplication(paymentApplication);

            var derivationLog = this.DatabaseSession.Derive();
            Assert.IsTrue(derivationLog.HasErrors);
            Assert.Contains(PaymentApplications.Meta.AmountApplied, derivationLog.Errors[0].RoleTypes);
        }
开发者ID:Allors,项目名称:apps,代码行数:45,代码来源:PaymentApplicationTests.cs


示例18: SetUp

        public void SetUp()
        {
            var configuration = new Databases.Memory.IntegerId.Configuration { ObjectFactory = Config.ObjectFactory, WorkspaceFactory = new WorkspaceFactory() };
            Config.Default = new Databases.Memory.IntegerId.Database(configuration);

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("nl-BE");

            var database = Config.Default;
            database.Init();

            using (var session = database.CreateSession())
            {
                new Setup(session).Apply();

                session.Commit();

                using (var stringWriter = new StringWriter())
                {
                    using (var writer = new XmlTextWriter(stringWriter))
                    {
                        database.Save(writer);
                        MinimalXml = stringWriter.ToString();
                    }
                }

                var singleton = Singleton.Instance(session);
                singleton.Guest = new PersonBuilder(session).WithUserName("guest").WithLastName("guest").Build();

                var administrator = new PersonBuilder(session).WithUserName("administrator").WithLastName("Administrator").Build();
                var administrators = new UserGroups(session).Administrators;
                administrators.AddMember(administrator);

                session.Derive(true);
                session.Commit();

                using (var stringWriter = new StringWriter())
                {
                    using (var writer = new XmlTextWriter(stringWriter))
                    {
                        database.Save(writer);
                        DefaultXml = stringWriter.ToString();
                    }
                }
            }
        }
开发者ID:whesius,项目名称:allors,代码行数:45,代码来源:Fixture.cs


示例19: PersonBuilder

        public void GivenCurrentUserIsUnknown_WhenAccessingFaceToFaceCommunicationWithoutOwner_ThenDefaultSecurityTokenIsApplied()
        {
            var participant1 = new PersonBuilder(this.DatabaseSession).WithLastName("participant1").Build();
            var participant2 = new PersonBuilder(this.DatabaseSession).WithLastName("participant2").Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var communication = new FaceToFaceCommunicationBuilder(this.DatabaseSession)
                .WithSubject("subject")
                .WithParticipant(participant1)
                .WithParticipant(participant2)
                .WithActualStart(DateTime.UtcNow)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1, communication.SecurityTokens.Count);
            Assert.Contains(Singleton.Instance(this.DatabaseSession).DefaultSecurityToken, communication.SecurityTokens);
        }
开发者ID:Allors,项目名称:apps,代码行数:20,代码来源:FaceToFaceCommunicationTests.cs


示例20: DeniedPermissions

        public void DeniedPermissions()
        {
            var readOrganisationName = this.FindPermission(Organisations.Meta.Name, Operation.Read);
            var databaseRole = new RoleBuilder(this.DatabaseSession).WithName("Role").WithPermission(readOrganisationName).Build();
            var person = new PersonBuilder(this.DatabaseSession).WithFirstName("John").WithLastName("Doe").Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            new AccessControlBuilder(this.DatabaseSession).WithRole(databaseRole).WithSubject(person).Build();
            this.DatabaseSession.Commit();

            var sessions = new ISession[] { this.DatabaseSession, this.CreateWorkspaceSession() };
            foreach (var session in sessions)
            {
                session.Commit();

                var organisation = new OrganisationBuilder(session).WithName("Organisation").Build();

                var token = new SecurityTokenBuilder(session).Build();
                organisation.AddSecurityToken(token);

                var role = (Role)session.Instantiate(new Roles(this.DatabaseSession).FindBy(Roles.Meta.Name, "Role"));
                var accessControl = (AccessControl)session.Instantiate(role.AccessControlsWhereRole.First);
                accessControl.AddObject(token);

                Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);

                var accessList = new AccessControlList(organisation, person);

                Assert.IsTrue(accessList.CanRead(Organisations.Meta.Name));

                organisation.AddDeniedPermission(readOrganisationName);

                accessList = new AccessControlList(organisation, person);

                Assert.IsFalse(accessList.CanRead(Organisations.Meta.Name));

                session.Rollback();
            }
        }
开发者ID:whesius,项目名称:allors,代码行数:41,代码来源:AccessControlListTests.cs



注:本文中的PersonBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Persona类代码示例发布时间:2022-05-24
下一篇:
C# Person类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap