Пример #1
0
        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));
        }
Пример #2
0
        protected override void BaseSetup(Setup setup)
        {
            var employeeUserGroup     = new UserGroups(this.Session).Employees;
            var internalOrganisations = new Organisations(this.Session).InternalOrganisations();

            var people = new People(this.Session).Extent();

            var employeesByEmployer = new Employments(this.Session).Extent()
                                      .GroupBy(v => v.Employer)
                                      .ToDictionary(v => v.Key, v => new HashSet <Person>(v.Select(w => w.Employee).ToArray()));

            foreach (Person person in people)
            {
                foreach (var internalOrganisation in internalOrganisations)
                {
                    employeeUserGroup.AddMember(person);

                    if (employeesByEmployer.TryGetValue(internalOrganisation, out var employees))
                    {
                        if (employees.Contains(person))
                        {
                            break;
                        }
                    }

                    new EmploymentBuilder(this.Session).WithEmployer(internalOrganisation).WithEmployee(person).Build();
                }
            }
        }
Пример #3
0
        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));
        }
Пример #4
0
        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));
        }
Пример #5
0
        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));
        }
Пример #6
0
        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));
        }
Пример #7
0
        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));
        }