using System.IO; using System.Text; using Centron.BusinessLogic; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Data.Entities.Administration; using Centron.Data.WebServices.Sales.Receipts.Offers; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.ITscopeOffer { public class ITscopeOfferTests : EndToEndTest { public ITscopeOfferTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { this.Verifier.Settings.IgnoreProperty(f => f.PurchaseBasePrice); this.Verifier.Settings.IgnoreProperty(f => f.OriginalPurchasePrice); // Have to ignore ManufacturerCode as well, because the articles don't exist at ITscope anymore, // so we fall back to ARTIKNEU, and have a GUID in the ManufacturerCode this.Verifier.Settings.IgnoreProperty(f => f.ManufacturerCode); } [Fact(Skip = "Depends on ITscope API which sometimes changes it's data and then this test is flaky.")] public override void Execute() { // Make sure the company-name is included in the invoice-address and delivery-address this.CreateOffer("OpenTransOffer1"); // Make sure the special characters work correctly this.CreateOffer("OpenTransOffer2"); } private void CreateOffer(string name) { var openTransDocument = this.GetOpenTransDocument(name + ".xml"); using (var session = new BLSession()) { int customerI3D = 10000; var user = session.GetBL().GetAppUser(f => f.I3D == 11); var offer = session.GetBL().CreateOfferFromITscope(customerI3D, null, null, null, openTransDocument, user); this.Verifier.Verify(name, offer); } } private string GetOpenTransDocument(string name) { using (var stream = this.GetType().Assembly.GetManifestResourceStream(this.GetType(), name)) using (var reader = new StreamReader(stream, Encoding.UTF8)) { return reader.ReadToEnd(); } } } }