public void SalesOrder() { var customer = new PersonBuilder(this.Session).WithFirstName("Koen").WithUserName("customer").Build(); new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).WithInternalOrganisation(this.InternalOrganisation).Build(); var mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build(); this.Session.Derive(); var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); var order = new SalesOrderBuilder(this.Session) .WithTakenBy(this.InternalOrganisation) .WithBillToCustomer(customer) .WithShipToCustomer(customer) .WithAssignedShipToAddress(new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build()) .Build(); this.Session.Derive(); Assert.Equal(new SalesOrderStates(this.Session).Provisional, order.SalesOrderState); var acl = new AccessControlLists(employee)[order]; Assert.False(acl.CanExecute(M.SalesOrder.DoTransfer)); Assert.False(acl.CanWrite(M.SalesOrder.Description)); Assert.True(acl.CanRead(M.SalesOrder.Description)); }
public void Person() { var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); var acl = new AccessControlLists(employee)[employee]; Assert.True(acl.CanRead(M.Person.FirstName)); Assert.False(acl.CanWrite(M.Person.FirstName)); }
public void Good() { var good = new Goods(this.Session).Extent().First(); var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); var acl = new AccessControlLists(employee)[good]; Assert.True(acl.CanRead(M.Good.Name)); Assert.False(acl.CanWrite(M.Good.Name)); }
public void UserGroup() { var userGroup = new UserGroups(this.Session).Administrators; var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); var acl = new AccessControlLists(employee)[userGroup]; Assert.True(acl.CanRead(M.UserGroup.Members)); Assert.False(acl.CanWrite(M.UserGroup.Members)); }
public void GivenOrderItem_WhenObjectStateIsPartiallyReceived_ThenProductChangeIsNotAllowed() { var administrator = new PersonBuilder(this.Session).WithFirstName("Koen").WithUserName("admin").Build(); var administrators = new UserGroups(this.Session).Administrators; administrators.AddMember(administrator); this.Session.Derive(); this.Session.Commit(); this.InstantiateObjects(this.Session); User user = this.Administrator; this.Session.SetUser(user); var item = new PurchaseOrderItemBuilder(this.Session) .WithPart(this.finishedGood) .WithQuantityOrdered(10) .WithAssignedUnitPrice(5) .Build(); this.order.AddPurchaseOrderItem(item); this.order.SetReadyForProcessing(); this.Session.Derive(); var shipment = new PurchaseShipmentBuilder(this.Session).WithShipmentMethod(new ShipmentMethods(this.Session).Ground).WithShipFromParty(this.order.TakenViaSupplier).Build(); this.Session.Derive(); var shipmentItem = new ShipmentItemBuilder(this.Session).WithPart(this.finishedGood).WithQuantity(10).WithUnitPurchasePrice(1).Build(); shipment.AddShipmentItem(shipmentItem); this.Session.Derive(); new ShipmentReceiptBuilder(this.Session) .WithQuantityAccepted(3) .WithShipmentItem(shipmentItem) .WithOrderItem(item) .WithFacility(shipmentItem.StoredInFacility) .Build(); this.Session.Derive(); Assert.Equal(new PurchaseOrderItemShipmentStates(this.Session).PartiallyReceived, item.PurchaseOrderItemShipmentState); var acl = new AccessControlLists(this.Session.GetUser())[item]; Assert.False(acl.CanWrite(M.PurchaseOrderItem.Part)); }
public void WorkTask_StateCancelled_TimeEntry() { var customer = new OrganisationBuilder(this.Session).WithName("Org1").Build(); var internalOrganisation = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation); new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build(); var workTask = new WorkTaskBuilder(this.Session).WithName("Activity").WithCustomer(customer).WithTakenBy(internalOrganisation).Build(); this.Session.Derive(); var employee = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build(); new EmploymentBuilder(this.Session).WithEmployee(employee).WithEmployer(internalOrganisation).Build(); this.Session.Derive(); var timeEntry = new TimeEntryBuilder(this.Session) .WithRateType(new RateTypes(this.Session).StandardRate) .WithFromDate(DateTimeFactory.CreateDateTime(this.Session.Now())) .WithTimeFrequency(new TimeFrequencies(this.Session).Hour) .WithWorkEffort(workTask) .Build(); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntry); this.Session.Derive(); workTask.Cancel(); this.Session.Derive(); Assert.Equal(new WorkEffortStates(this.Session).Cancelled, workTask.WorkEffortState); User user = this.Administrator; this.Session.SetUser(user); var acl = new AccessControlLists(this.Administrator)[timeEntry]; Assert.False(acl.CanWrite(M.TimeEntry.AmountOfTime)); }
public void WorkTaskNewInSession() { var customer = new OrganisationBuilder(this.Session).WithName("Org1").Build(); var internalOrganisation = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation); new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build(); var workTask = new WorkTaskBuilder(this.Session).WithName("worktask").WithCustomer(customer).Build(); this.Session.Derive(); var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); Assert.True(workTask.Strategy.IsNewInSession); var acl = new AccessControlLists(employee)[workTask]; Assert.True(acl.CanRead(M.WorkTask.Name)); Assert.True(acl.CanWrite(M.WorkTask.Name)); }
public void SalesInvoice() { var customer = new OrganisationBuilder(this.Session).WithName("Org1").Build(); var contactMechanism = new PostalAddressBuilder(this.Session) .WithAddress1("Haverwerf 15") .WithLocality("Mechelen") .WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE")) .Build(); var internalOrganisation = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation); new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build(); var salesInvoice = new SalesInvoiceBuilder(this.Session).WithBillToCustomer(customer).WithAssignedBillToContactMechanism(contactMechanism).Build(); this.Session.Derive(); var employee = new Employments(this.Session).Extent().Select(v => v.Employee).First(); this.Session.SetUser(employee); Assert.True(salesInvoice.Strategy.IsNewInSession); var acl = new AccessControlLists(employee)[salesInvoice]; Assert.True(acl.CanRead(M.SalesInvoice.Description)); Assert.False(acl.CanWrite(M.SalesInvoice.Description)); this.Session.Commit(); Assert.False(salesInvoice.Strategy.IsNewInSession); acl = new AccessControlLists(employee)[salesInvoice]; Assert.True(acl.CanRead(M.SalesInvoice.Description)); Assert.False(acl.CanWrite(M.SalesInvoice.Description)); }
public void GivenLoggedUserIsAdministrator_WhenAccessingSingleton_ThenLoggedInUserIsGrantedAccess() { var existingAdministrator = this.Administrator; var secondAdministrator = new PersonBuilder(this.Session).WithLastName("second admin").Build(); Assert.False(secondAdministrator.IsAdministrator()); var internalOrganisation = this.InternalOrganisation; this.Session.Derive(); User user = this.Administrator; this.Session.SetUser(user); var acl = new AccessControlLists(existingAdministrator)[internalOrganisation]; Assert.True(acl.CanRead(M.Organisation.Name)); acl = new AccessControlLists(existingAdministrator)[internalOrganisation]; Assert.True(acl.CanWrite(M.Organisation.Name)); var administrators = new UserGroups(this.Session).Administrators; administrators.AddMember(secondAdministrator); this.Session.Derive(); Assert.True(secondAdministrator.IsAdministrator()); acl = new AccessControlLists(existingAdministrator)[internalOrganisation]; Assert.True(acl.CanRead(M.Organisation.Name)); acl = new AccessControlLists(existingAdministrator)[internalOrganisation]; Assert.True(acl.CanWrite(M.Organisation.Name)); }