本文整理汇总了C#中PersonBuilder类的典型用法代码示例。如果您正苦于以下问题:C# PersonBuilder类的具体用法?C# PersonBuilder怎么用?C# PersonBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersonBuilder类属于命名空间,在下文中一共展示了PersonBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}
示例7: GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations
public void GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations()
{
var builder = new PersonBuilder(this.Session);
builder.Build();
Assert.IsFalse(this.Session.Derive().HasErrors);
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
});
}