Skip to content

Commit

Permalink
Update for Issue allors#46
Browse files Browse the repository at this point in the history
- Implements SalesOrder Transfer feature
- Domain Test (WIP)
  • Loading branch information
jubayerarefin committed Jul 21, 2020
1 parent 820a5d2 commit a352c57
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions Base/Database/Domain.Tests/Order/SalesOrderTransferTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,6 @@ namespace Allors.Domain

public class SalesOrderTransferTests : DomainTest
{
[Fact]
public void GivenSalesOrderBuilder_WhenProvisional_ThenOrderCanTranseft()
{
var customer = new PersonBuilder(this.Session).WithFirstName("Koen").Build();
var internalOrganisation = this.InternalOrganisation;

var anotherInternalOrganisation = new OrganisationBuilder(this.Session)
.WithIsInternalOrganisation(true)
.WithDoAccounting(false)
.WithName("another internalOrganisation")
.WithPreferredCurrency(new Currencies(this.Session).CurrencyByCode["EUR"])
.WithIncomingShipmentNumberPrefix("incoming shipmentno: ")
.WithPurchaseInvoiceNumberPrefix("incoming invoiceno: ")
.WithPurchaseOrderNumberPrefix("purchase orderno: ")
.WithSubAccountCounter(new CounterBuilder(this.Session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build())
.Build();

new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build();

var mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build();

this.Session.Derive();

var order = new SalesOrderBuilder(this.Session)
.WithTakenBy(this.InternalOrganisation)
.WithBillToCustomer(customer)
.WithShipToCustomer(customer)
.WithShipToAddress(new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build())
.Build();

this.Session.Derive();

var transfer = new SalesOrderTransferBuilder(this.Session)
.WithFrom(order)
.WithInternalOrganisation(anotherInternalOrganisation)
.Build();

this.Session.Derive();

Assert.True(transfer.ExistTo);
Assert.Equal(transfer.To.TakenBy, anotherInternalOrganisation);
Assert.Equal(order.ShipToCustomer, transfer.To.ShipToCustomer);
//TODO: Add More Asserts

}

[Fact]
public void GivenSalesOrderForItemsThatAreAvailable_WhenShipped_ThenOrderIsCompleted()
{
Expand Down Expand Up @@ -2733,6 +2687,52 @@ public class SalesOrderTransferSecurityTests : DomainTest
{
public override Config Config => new Config { SetupSecurity = true };

[Fact]
public void GivenSalesOrderBuilder_WhenProvisional_ThenOrderCanTransfer()
{
var customer = new PersonBuilder(this.Session).WithFirstName("Koen").Build();
var internalOrganisation = this.InternalOrganisation;

var anotherInternalOrganisation = new OrganisationBuilder(this.Session)
.WithIsInternalOrganisation(true)
.WithDoAccounting(false)
.WithName("another internalOrganisation")
.WithPreferredCurrency(new Currencies(this.Session).CurrencyByCode["EUR"])
.WithIncomingShipmentNumberPrefix("incoming shipmentno: ")
.WithPurchaseInvoiceNumberPrefix("incoming invoiceno: ")
.WithPurchaseOrderNumberPrefix("purchase orderno: ")
.WithSubAccountCounter(new CounterBuilder(this.Session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build())
.Build();

new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build();

var mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build();

this.Session.Derive();

var order = new SalesOrderBuilder(this.Session)
.WithTakenBy(this.InternalOrganisation)
.WithBillToCustomer(customer)
.WithShipToCustomer(customer)
.WithShipToAddress(new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build())
.Build();

this.Session.Derive();

var transfer = new SalesOrderTransferBuilder(this.Session)
.WithFrom(order)
.WithInternalOrganisation(anotherInternalOrganisation)
.Build();

this.Session.Derive();

Assert.True(transfer.ExistTo);
Assert.Equal(transfer.To.TakenBy, anotherInternalOrganisation);
Assert.Equal(order.ShipToCustomer, transfer.To.ShipToCustomer);
//TODO: Add More Asserts

}

[Fact]
public void GivenSalesOrder_WhenObjectStateIsProvisional_ThenCheckTransitions()
{
Expand Down

0 comments on commit a352c57

Please sign in to comment.