using Centron.BusinessLogic.WebServices; using Centron.DAO.Mappings.Sales.Receipts; using Centron.DAO.Mappings.Sales.Receipts.Invoices; using Centron.Data.Entities.Sales.Receipts; using Centron.Data.Entities.Sales.Receipts.Invoices; using Centron.Data.WebServices.Sales.Receipts.Invoices; using Centron.Interfaces.Administration.Environment; using Centron.Interfaces.Sales.Receipts; using Centron.Interfaces.Sales.Receipts.Invoices; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Tool.hbm2ddl; namespace Centron.Tests.DAO.Mappings.Sales.Receipts; public class ReceiptBaseMapsTest { [Fact] public void ReceiptReceiverCanBeMapped() { var session = CreateSession(); var receipt = new ReceiptInvoice() { I3D = 1, CustomerI3D = 10, Information = "Information", ShowInformation = false, IsCashAsset = false, PurchaseOrderNumber = "12345", AdditionalText = "Additional text", ProjectNumber = "123456", DeliveryConditionText = "", PaymentConditionText = "", DeliveryAddress = "Delivery address", DeliveryAddressInformation = "", InvoiceAddress = "Invoice address", InvoiceAddressInformation = "", LicenseeAddress = "Licensee address", LicenseeAddressInformation = "", IsPartialDeliveryPossible = false, EsrAmount = "1", EsrCodelineAmount = "1", EsrReferenceNumber = "123", IsFixed = false, UsedAlternativeDeliveryAddress = false, UsedAlternativeInvoiceAddress = false, Provision = new List(), PaidFC = 2, ExternalInvoiceNumber = "345", CurrencyFactorIsFixed = true, CollectiveAccount = "Collective account", TrackingNumber = "567", TrackingNumberURL = "TrackURL", Number = 2, Date = DateTime.Now, Version = 1, State = ReceiptState.Active, BranchOrigin = BranchOrigin.Creator, CurrencyFactor = 1, CurrencyString = "€", ExclusiveOfVAT = false, Receiver = "Receiver", Phone = "12345", Fax = "12345", Email = "mail@a.com", Street = "Street", HasPostOfficeBox = false, PostOfficeBox = "", Zip = "12345", City = "City", ContactName = "Contact name", CreatedThroughApplicationVersion = "2.0.2504.5", ChangedThroughApplicationVersion = "", ChangedThroughApplication = CreatedThroughApplication.WebServices, ConcurrencyControlGuid = Guid.NewGuid(), ReceiptReceiver = new ReceiptReceiver() { CompanyName = "Company", Department = "Department", ContactName = "Contact", ContactDepartment = "C Department", Street = "Street", HouseNumber = "1", Zip = "12345", City = "City", Country = "Country", CountryI3D = 4, PostOfficeBox = "", HasPostOfficeBox = false, AdditionalAddressSupplement = "" }, ReceiptReceiverInvoice = new ReceiptReceiver() { CompanyName = "Company", Department = "Department", ContactName = "Contact", ContactDepartment = "C Department", Street = "Street Invoice", HouseNumber = "1", Zip = "12345", City = "City", Country = "Country", CountryI3D = 4, PostOfficeBox = "", HasPostOfficeBox = false, AdditionalAddressSupplement = "" } , ReceiptReceiverLicense = new ReceiptReceiver() { CompanyName = "Company License", Department = "Department", ContactName = "Contact", ContactDepartment = "C Department", Street = "Street", HouseNumber = "1", Zip = "12345", City = "City", Country = "Country", CountryI3D = 4, PostOfficeBox = "", HasPostOfficeBox = false, AdditionalAddressSupplement = "" } }; session.Save(receipt); session.Flush(); var savedEntity = session.Get(1); Assert.NotNull(savedEntity); var dto = ObjectMapper.Map(savedEntity); Assert.NotNull(dto); Assert.Equal("Company License", dto.ReceiptReceiverLicense.CompanyName); var savedReceiptReceivers = session.Query().ToList(); Assert.Equal(3, savedReceiptReceivers.Count); } public ISession CreateSession() { var fluentConfiguration = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.FluentMappings.Add()) .Mappings(m => m.FluentMappings.Add()) .Mappings(m => m.FluentMappings.Add()) ; ISessionFactory sessionFactory = fluentConfiguration.BuildSessionFactory(); ISession session = sessionFactory.OpenSession(); new SchemaExport(fluentConfiguration.BuildConfiguration()).Execute(true, true, false, session.Connection, Console.Out); return session; } }