QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
295 lines
13 KiB
C#
295 lines
13 KiB
C#
using Centron.BusinessLogic.Sales.Receipts.Internal;
|
|
using Centron.DAO;
|
|
using Centron.DAO.Mappings;
|
|
using Centron.DAO.Mappings.Accounts;
|
|
using Centron.DAO.Mappings.Administration;
|
|
using Centron.DAO.Mappings.Administration.Company;
|
|
using Centron.DAO.Mappings.Administration.Employees;
|
|
using Centron.DAO.Mappings.CustomerArea;
|
|
using Centron.DAO.Mappings.CustomerArea.Support;
|
|
using Centron.DAO.Mappings.Sales.Receipts;
|
|
using Centron.DAO.Mappings.States;
|
|
using Centron.Tests.BL.DatabaseMappings;
|
|
using Centron.Data.Entities.Accounts;
|
|
using Centron.Data.Entities.CustomerArea;
|
|
using Centron.Interfaces.Accounts;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts.DataAndResults;
|
|
using Centron.DAO.Mappings.Administration.Settings;
|
|
using Centron.DAO.Mappings.Sales.Receipts.ContractLists;
|
|
using Centron.DAO.Mappings.Sales.Receipts.CreditVouchers;
|
|
using Centron.DAO.Mappings.Sales.Receipts.DeliveryLists;
|
|
using Centron.DAO.Mappings.Sales.Receipts.Invoices;
|
|
using Centron.DAO.Mappings.Sales.Receipts.Offers;
|
|
using Centron.DAO.Mappings.Sales.Receipts.Orders;
|
|
using Centron.DAO.Mappings.Sales.Receipts.PickupLists;
|
|
using Centron.DAO.Mappings.TemporaryEntities;
|
|
using Centron.Data.Entities.Administration.MasterData;
|
|
using Centron.Data.Entities.Sales.Receipts;
|
|
using Centron.Data.Entities.Sales.Receipts.Offers;
|
|
using Centron.Interfaces.Sales.Receipts;
|
|
using Centron.Tests.BL.Fixtures;
|
|
using FluentNHibernate.Cfg;
|
|
using FluentNHibernate.Cfg.Db;
|
|
using JetBrains.Annotations;
|
|
using NHibernate;
|
|
using NHibernate.Tool.hbm2ddl;
|
|
using AccountType = Centron.Data.Entities.Accounts.AccountType;
|
|
|
|
namespace Centron.Tests.BL.Sales.Receipts.Internal;
|
|
|
|
[TestSubject(typeof(ReceiptReceiverUpdaterBL))]
|
|
public class ReceiptReceiverUpdaterBLTest : LicenseManagerFixture
|
|
{
|
|
|
|
[Fact]
|
|
public void FindReceiptReceiverForCustomerAccounts_ReturnsUpdates_ForAlternativeReceivers()
|
|
{
|
|
var session = CreateSession();
|
|
var country = new Country() { Name = "Deutschland" };
|
|
session.Save(country, 1);
|
|
var address = new AccountAddress()
|
|
{
|
|
Street = "Main Street 123a",
|
|
Zip = "12345",
|
|
City = "Munich",
|
|
PrintDepartment = true,
|
|
PostOfficeBox = string.Empty,
|
|
CountryI3D = 1,
|
|
};
|
|
session.Save(address, 2);
|
|
var contact = new AccountAddressContact()
|
|
{
|
|
Firstname = "John",
|
|
Lastname = "Doe",
|
|
DepartmentText = "Dept",
|
|
};
|
|
session.Save(contact, 3);
|
|
|
|
var account = new Account()
|
|
{
|
|
I3D = 100,
|
|
Name = "Main Account",
|
|
Number = 1,
|
|
IsActive = true,
|
|
IsLocked = false
|
|
};
|
|
session.Save(account, 100);
|
|
|
|
var accountType = new AccountType()
|
|
{
|
|
Name = "Kunde",
|
|
I3D = 200,
|
|
Kind = AccountTypeKind.Customer
|
|
};
|
|
session.Save(accountType, 200);
|
|
|
|
var accountCustomer = new AccountCustomer()
|
|
{
|
|
I3D = 300,
|
|
AlternativeDeliveryReceiver = "Main Account\nDept\nJohn Doe\nMain Street 123a\n12345 Munich",
|
|
AlternativeDeliveryAddressI3D = 2,
|
|
AlternativeDeliveryAddressContactI3D = 3,
|
|
AlternativeDeliveryAccountI3D = 100,
|
|
AlternativeInvoiceReceiver = "Dept\nMr John Doe\nMain Street 123a\n12345 Munich",
|
|
AlternativeInvoiceAddressI3D = 2,
|
|
AlternativeInvoiceAddressContactI3D = 3,
|
|
AlternativeInvoiceAccountI3D = 100
|
|
};
|
|
session.Save(accountCustomer, 300);
|
|
|
|
var typeBinding = new AccountTypeToAccount()
|
|
{
|
|
I3D = 400,
|
|
AccountI3D = 100,
|
|
AccountTypeI3D = 200,
|
|
AccountCustomerI3D = 300
|
|
};
|
|
session.Save(typeBinding, 400);
|
|
|
|
session.Flush();
|
|
|
|
var daoSession = new DAOSession(session);
|
|
var bl = new ReceiptReceiverUpdaterBL(daoSession);
|
|
|
|
var result = bl.FindReceiptReceiverForCustomerAccounts();
|
|
|
|
Assert.Equal(ResultStatus.Success, result.Status);
|
|
Assert.NotNull(result.Data);
|
|
Assert.Equal(2, result.Data.Count);
|
|
|
|
var delivery = result.Data.First(f => f.Type == ReceiptReceiverUpdateInformation.ReceiptReceiverType.Delivery);
|
|
Assert.True(delivery.Update);
|
|
Assert.Equal("Main Account\nDept\nJohn Doe\nMain Street 123a\n12345 Munich", delivery.Receiver);
|
|
Assert.NotNull(delivery.ReceiptReceiver);
|
|
Assert.Equal("Main Account", delivery.ReceiptReceiver.CompanyName);
|
|
|
|
var invoice = result.Data.First(f => f.Type == ReceiptReceiverUpdateInformation.ReceiptReceiverType.Invoice);
|
|
Assert.False(invoice.Update);
|
|
Assert.Equal("Dept\nMr John Doe\nMain Street 123a\n12345 Munich", invoice.Receiver);
|
|
Assert.Null(invoice.ReceiptReceiver);
|
|
Assert.Equal("Nicht erkannte Zeilen: " + Environment.NewLine + "Mr John Doe" + Environment.NewLine + "Mögliche Zeilen: " + Environment.NewLine + "John Doe, " + Environment.NewLine + "Deutschland, " + Environment.NewLine + "Main Account", invoice.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void FindReceiptReceiverForReceipts_ReturnsUpdates_ForAlternativeReceivers()
|
|
{
|
|
var session = CreateSession();
|
|
var country = new Country()
|
|
{
|
|
Name = "Deutschland"
|
|
};
|
|
session.Save(country, 1);
|
|
var address = new Address()
|
|
{
|
|
Street = "Main Street 123a",
|
|
Zip = "12345",
|
|
City = "Munich",
|
|
Country = country,
|
|
PrintType = true,
|
|
PrintContactPerson = true,
|
|
PrintDepartmentContact = 1,
|
|
PrintDepartment = true,
|
|
HasPostOfficeBox = false,
|
|
PostOfficeBox = "",
|
|
Department = "Department",
|
|
Language = country,
|
|
Currency = country,
|
|
VariableAddress = 0
|
|
};
|
|
session.Save(address, 2);
|
|
var department = new ContactDepartment()
|
|
{
|
|
Department = "Contact Department"
|
|
};
|
|
session.Save(department, 3);
|
|
var contact = new ContactPerson()
|
|
{
|
|
FirstName = "John",
|
|
LastName = "Doe",
|
|
Department = department,
|
|
Address = address
|
|
};
|
|
session.Save(contact, 4);
|
|
var customer = new CustomerCompact()
|
|
{
|
|
Name = "Tree"
|
|
};
|
|
session.Save(customer, 5);
|
|
|
|
var receipt = new ReceiptOffer()
|
|
{
|
|
CustomerI3D = 5,
|
|
DeliveryAddress = "Tree\nContact Department\nJohn Doe\nMain Street 123a\n12345 Munich",
|
|
DeliveryAddressCustomerI3D = 5,
|
|
DeliveryAddressAddressI3D = 2,
|
|
DeliveryAddressContactPersonI3D = 4,
|
|
InvoiceAddress = "Tree\nContact Department\nMr John Doe\nMain Street 123a\n12345 Munich",
|
|
InvoiceAddressCustomerI3D = 5,
|
|
InvoiceAddressAddressI3D = 2,
|
|
InvoiceAddressContactPersonI3D = 4,
|
|
Receiver = "Receiver",
|
|
Phone = "1234",
|
|
Fax = "1234",
|
|
Email = "test@test.de",
|
|
CreatedThroughApplicationVersion = "2.0.0",
|
|
ChangedThroughApplicationVersion = "2.0.0",
|
|
CurrencyString = "€",
|
|
Street = "Street",
|
|
PostOfficeBox = "",
|
|
City = "City",
|
|
Zip = "12345",
|
|
ContactName = "Name",
|
|
Information = "",
|
|
Number = 1234,
|
|
Date = DateTime.Now,
|
|
Version = 1,
|
|
State = ReceiptState.Active,
|
|
BranchOrigin = BranchOrigin.Creator,
|
|
CurrencyFactor = 1,
|
|
PurchaseOrderNumber = "1234",
|
|
};
|
|
session.Save(receipt, 7);
|
|
var provisionSchema = new ReceiptProvisionSchema
|
|
{
|
|
Name = "Schema",
|
|
};
|
|
session.Save(provisionSchema, 8);
|
|
session.Flush();
|
|
|
|
var daoSession = new DAOSession(session);
|
|
var bl = new ReceiptReceiverUpdaterBL(daoSession);
|
|
|
|
var result = bl.FindReceiptReceiverForReceipts();
|
|
|
|
Assert.Equal(ResultStatus.Success, result.Status);
|
|
Assert.NotNull(result.Data);
|
|
Assert.Equal(3, result.Data.Count);
|
|
|
|
var delivery = result.Data.First(f => f.Type == ReceiptReceiverUpdateInformation.ReceiptReceiverType.Delivery);
|
|
Assert.True(delivery.Update);
|
|
Assert.Equal("Tree\nContact Department\nJohn Doe\nMain Street 123a\n12345 Munich", delivery.Receiver);
|
|
Assert.NotNull(delivery.ReceiptReceiver);
|
|
Assert.Equal("Tree", delivery.ReceiptReceiver.CompanyName);
|
|
|
|
var invoice = result.Data.First(f => f.Type == ReceiptReceiverUpdateInformation.ReceiptReceiverType.Invoice);
|
|
Assert.False(invoice.Update);
|
|
Assert.Equal("Tree\nContact Department\nMr John Doe\nMain Street 123a\n12345 Munich", invoice.Receiver);
|
|
Assert.Null(invoice.ReceiptReceiver);
|
|
Assert.Equal("Nicht erkannte Zeilen: " + Environment.NewLine + "Mr John Doe" + Environment.NewLine + "Mögliche Zeilen: " + Environment.NewLine + "John Doe, " + Environment.NewLine + "Department, " + Environment.NewLine + "Deutschland" , invoice.Message);
|
|
}
|
|
|
|
|
|
public ISession CreateSession()
|
|
{
|
|
var fluentConfiguration = Fluently.Configure()
|
|
.Database(SQLiteConfiguration.Standard.InMemory)
|
|
.Mappings(m => m.FluentMappings.Add<AddressMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<CountryMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptReceiverMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ContactPersonMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<EmployeeCompactMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AppUserMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<SupportLevelMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<CustomerDepartmentMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<CustomerSalutationMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<MandatorMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<FederalStateMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AppUserGroupMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AppRightMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<CustomerCompactMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<SupplierMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountAddressMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountCustomerMapsForTest>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountTypeMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountTypeToAccountMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<GeoInfoMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptOfferMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptOrderMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptOrderItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptInvoiceMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptInvoiceItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptContractMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptContractItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptCreditVoucherMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptCreditVoucherItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptProvisionSchemaMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptProvisionSchemaItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptProvisionItemEntityMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptOfferItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptDeliveryListMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptDeliveryListItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptPickupListMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ReceiptPickupListItemMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountAddressContactMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AppSettingMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<ApplicationSettingMaps>())
|
|
.Mappings(m => m.FluentMappings.Add<AccountSearchItemAccMaps>());
|
|
ISessionFactory sessionFactory = fluentConfiguration.BuildSessionFactory();
|
|
ISession session = sessionFactory.OpenSession();
|
|
|
|
new SchemaExport(fluentConfiguration.BuildConfiguration()).Execute(true, true, false, session.Connection, Console.Out);
|
|
return session;
|
|
}
|
|
} |