Files
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
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
2026-08-26 07:43:51 +02:00

637 lines
30 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Centron.BusinessLogic;
using Centron.BusinessLogic.EmployeeArea;
using Centron.BusinessLogic.WebServices.Accounts.Campaigns;
using Centron.BusinessLogic.WebServices.Administration.FileManagement;
using Centron.BusinessLogic.WebServices.Administration.HourlySurchargeRates;
using Centron.BusinessLogic.WebServices.Sales.Receipts.ReceiptSearch;
using Centron.Data.Entities.Administration;
using Centron.Data.Entities.Administration.Logins;
using Centron.Data.WebServices.Administration.Employees;
using Centron.Data.WebServices.Sales.Receipts.ReceiptSearch;
using Centron.Interfaces;
using Centron.Interfaces.Accounts.Campaigns;
using Centron.Interfaces.BL;
using Centron.Interfaces.Sales.Receipts.ReceiptSearch;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Accounts.Campaigns;
using CentronSoftware.Centron.WebServices.Entities.Administration.FileManagement.SharedDocuments;
using CentronSoftware.Centron.WebServices.Entities.Administration.HourlySurchargeRates;
using CentronSoftware.Centron.WebServices.RestRequests.SharedDocuments;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.ReceiptSearch
{
public class ReceiptSearchTest : EndToEndTest
{
public ReceiptSearchTest(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public override void Execute()
{
this.Arrange();
// No Filtering
this.SearchReceipts("NoFiltering", new ReceiptSearchFilter());
this.SearchReceipts("NoFiltering_IncludeClosed", new ReceiptSearchFilter { IncludeClosedReceipts = true });
// SearchText
this.SearchReceipts("SearchText_Celos", new ReceiptSearchFilter { SearchText = "Celos" });
this.SearchReceipts("SearchText_IsReceiptNumber", new ReceiptSearchFilter { SearchText = "10331" });
this.SearchReceipts("SearchText_Duplex_ReceiptItems", new ReceiptSearchFilter { SearchText = "Duplex", SearchInReceiptItemText = true });
this.SearchReceipts("SearchText_Scale_Fuji_ReceiptItems", new ReceiptSearchFilter { SearchText = "Scale Fuji", SearchInReceiptItemText = true, IncludeClosedReceipts = true});
// AccountI3D
this.SearchReceipts("AccountI3D_10000", new ReceiptSearchFilter { AccountI3D = 10000 }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Equal(filter.AccountI3D, f.AccountI3D);
});
});
this.SearchReceipts("AccountI3D_DoesntExist", new ReceiptSearchFilter { AccountI3D = 123456789 }, (filter, receipts) =>
{
Assert.Empty(receipts);
});
// ReceiptNumber
this.SearchReceipts("ReceiptNumber_IsActive", new ReceiptSearchFilter { ReceiptNumber = 30176 }, (filter, receipts) =>
{
Assert.Collection(receipts, f =>
{
Assert.Equal(filter.ReceiptNumber, f.Number); // The receipt is found
});
});
this.SearchReceipts("ReceiptNumber_IsNotActive", new ReceiptSearchFilter { ReceiptNumber = 10070 }, (filter, receipts) =>
{
Assert.Empty(receipts); // Can't be found
});
this.SearchReceipts("ReceiptNumber_IsNotActive_IncludeClosed", new ReceiptSearchFilter { ReceiptNumber = 10070, IncludeClosedReceipts = true }, (filter, receipts) =>
{
Assert.Collection(receipts, f =>
{
Assert.Equal(10070, f.Number); // Can be found now!
});
});
this.SearchReceipts("ReceiptNumber_DoesntExist", new ReceiptSearchFilter { ReceiptNumber = 123456789 }, (filter, receipts) =>
{
Assert.Empty(receipts); // Nothing is found
});
// ReceiptKinds
var allReceiptKinds = new[]
{
// Customer
CentronObjectKindNumeric.OfferClass,
CentronObjectKindNumeric.OrderClass,
CentronObjectKindNumeric.DeliveryListClass,
CentronObjectKindNumeric.PickupListClass,
CentronObjectKindNumeric.InvoiceClass,
CentronObjectKindNumeric.CreditVoucherClass,
CentronObjectKindNumeric.ContractClass,
// Supplier
CentronObjectKindNumeric.SupplierOffer,
CentronObjectKindNumeric.SupplierOrder,
CentronObjectKindNumeric.SupplierDeliveryList,
CentronObjectKindNumeric.SupplierInvoice,
CentronObjectKindNumeric.SupplierCreditVoucher,
};
foreach (var receiptKind in allReceiptKinds)
{
this.SearchReceipts($"ReceiptKind_{receiptKind}", new ReceiptSearchFilter { ReceiptKinds = new List<CentronObjectKindNumeric> { receiptKind }}, (filter, receipts) =>
{
var countOfOtherReceiptKinds = receipts
.Count(f => f.ObjectKind != (int) filter.ReceiptKinds.First());
Assert.Equal(0, countOfOtherReceiptKinds);
});
}
// DateFrom
this.SearchReceipts("DateFrom", new ReceiptSearchFilter { DateFrom = new DateTime(2017, 1, 1)}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.True(f.Date >= filter.DateFrom);
});
});
// DateTo
this.SearchReceipts("DateTo", new ReceiptSearchFilter { DateTo = new DateTime(2012, 12, 31)}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.True(f.Date <= filter.DateTo);
});
});
foreach (var receiptKind in allReceiptKinds)
{
// Has right to see receipts
this.SearchReceipts($"HasShowRight_{receiptKind}", new ReceiptSearchFilter { ReceiptKinds = new List<CentronObjectKindNumeric>() { receiptKind } }, (filter, receipts) =>
{
Assert.True(receipts.Any());
});
// Does not have right to see receipts
using (var session = new BLSession())
{
var userWithoutRight = new LoggedInUser(session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 20));
this.SearchReceipts($"HasNoRight_{receiptKind}", new ReceiptSearchFilter { ReceiptKinds = new List<CentronObjectKindNumeric>() { receiptKind } }, (filter, receipts) =>
{
Assert.False(receipts.Any());
}, userWithoutRight);
}
}
// OnlyOwn
this.SearchReceipts("OnlyOwn", new ReceiptSearchFilter { OnlyOwn = true }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(new[] {f.Editor, f.Adviser1, f.Adviser2}, d => d == "ADMIN");
});
});
// OnlyOwnBranch
this.SearchReceipts("OnlyOwnBranch", new ReceiptSearchFilter { OnlyOwnBranch = true }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(new int?[] {null, 0}, d => d == f.BranchI3D);
});
});
this.SearchReceipts("OnlyOwnBranch_IncludeClosed", new ReceiptSearchFilter { OnlyOwnBranch = true, IncludeClosedReceipts = true }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(new int?[] {null, 0}, d => d == f.BranchI3D);
});
});
// PaymentConditionI3D
this.SearchReceipts("PaymentConditionI3D", new ReceiptSearchFilter { PaymentConditionI3D = 7 }, (filter, receipts) =>
{
// When filtering for a payment-condition, we don't get any receipts that DONT HAVE a payment-condition
//
// I consider this the correct behavior
// If you filter for "all receipts with PaymentCondition X", then the result should only contain receipts with that payment-condition
// And not additional baggage that you didn't ask for
var receiptsWithoutPaymentCondition = new []
{
(int)CentronObjectKindNumeric.PickupListClass,
(int)CentronObjectKindNumeric.CreditVoucherClass,
(int)CentronObjectKindNumeric.SupplierOffer
};
Assert.All(receipts, f =>
{
// All need to have the given payment-condition
Assert.Equal(filter.PaymentConditionI3D, f.PaymentConditionI3D);
// There should not be any receipts without a payment-condition
Assert.DoesNotContain(receiptsWithoutPaymentCondition, d => d == f.ObjectKind);
});
});
// DeliveryConditionI3D
this.SearchReceipts("DeliveryConditionI3D", new ReceiptSearchFilter { DeliveryConditionI3D = 21 }, (filter, receipts) =>
{
// There are quite a couple of receipts that don't have a delivery-condition
// They are all filtered out
// These here are getting filtered out, that's good
var receiptsWithoutDeliveryCondition = new []
{
(int)CentronObjectKindNumeric.PickupListClass,
(int)CentronObjectKindNumeric.CreditVoucherClass,
(int)CentronObjectKindNumeric.SupplierOffer,
(int)CentronObjectKindNumeric.SupplierDeliveryList,
(int)CentronObjectKindNumeric.SupplierInvoice,
(int)CentronObjectKindNumeric.SupplierCreditVoucher,
};
Assert.All(receipts, f =>
{
// All need to have the given payment-condition
Assert.Equal(filter.DeliveryConditionI3D, f.DeliveryConditionI3D);
// There should not be any receipts without a payment-condition
Assert.DoesNotContain(receiptsWithoutDeliveryCondition, d => d == f.ObjectKind);
});
});
// SupplierI3Ds
this.SearchReceipts("SupplierI3Ds", new ReceiptSearchFilter { SupplierI3Ds = new List<int> { 70004 }, IncludeClosedReceipts = true }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Equal(filter.SupplierI3Ds.First(), f.AccountI3D);
});
});
// EmployeeI3Ds
this.SearchReceipts("EmployeeI3Ds", new ReceiptSearchFilter { EmployeeI3Ds = new List<int> { 22 } }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(new[] {f.Editor, f.Adviser1, f.Adviser2}, d => d == "ADMIN");
});
});
// HourlySurchargeRateI3Ds
this.SearchReceipts("HourlySurchargeRateI3Ds", new ReceiptSearchFilter { HourlySurchargeRateI3Ds = new List<int> { 1 }}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Equal(filter.HourlySurchargeRateI3Ds.First(), f.HourlySurchargeRateI3D);
});
});
// ReceiptI3Ds
this.SearchReceipts("ReceiptI3Ds", new ReceiptSearchFilter { ReceiptI3Ds = new List<int> { 1 }}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(filter.ReceiptI3Ds, d => d == f.I3D);
});
});
// AccountNumbers
this.SearchReceipts("AccountNumbers", new ReceiptSearchFilter { AccountNumbers = new List<int> { 70004, 10000 }}, (filter, receipts) =>
{
// It's like a combination of AccountI3D and SupplierI3Ds - but it works without any weird quirks!
Assert.All(receipts, f =>
{
Assert.Contains(filter.AccountNumbers, d => d == f.AccountNumber);
});
});
// GrossPriceFrom
this.SearchReceipts("GrossPriceFrom", new ReceiptSearchFilter { GrossPriceFrom = 2000 }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.True(f.NetPriceComplete + f.TaxPriceComplete >= filter.GrossPriceFrom);
});
});
// GrossPriceTo
this.SearchReceipts("GrossPriceTo", new ReceiptSearchFilter { GrossPriceTo = 2000 }, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.True(f.NetPriceComplete + f.TaxPriceComplete <= filter.GrossPriceTo);
});
});
// AccountName
this.SearchReceipts("AccountName_Ingram", new ReceiptSearchFilter { AccountName = "Ingram"}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(filter.AccountName, f.AccountName);
});
});
this.SearchReceipts("AccountName_Celos", new ReceiptSearchFilter { AccountName = "Celos"}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.Contains(filter.AccountName, f.AccountName);
});
});
// ChangedAfterDate
this.SearchReceipts("ChangedAfterDate_2017_01_01", new ReceiptSearchFilter { ChangedAfterDate = new DateTime(2017, 1, 1) });
this.SearchReceipts("ChangedAfterDate_2017_06_01", new ReceiptSearchFilter { ChangedAfterDate = new DateTime(2017, 6, 1) });
this.SearchReceipts("ChangedAfterDate_2017_08_01", new ReceiptSearchFilter { ChangedAfterDate = new DateTime(2017, 8, 1) });
// AccountI3D and SupplierI3Ds at the same time
this.SearchReceipts("AccountI3DAndSupplierI3Ds", new ReceiptSearchFilter { AccountI3D = 10000, SupplierI3Ds = new List<int> { 70004 }});
// Paging
this.SearchReceiptsWithPaging("AccountName_Ingram", new ReceiptSearchFilter { AccountName = "Ingram" });
// CampaignSearch
this.SearchReceipts("AccountI3DAndCampaignI3D", new ReceiptSearchFilter { AccountI3D = 10000, IncludeClosedReceipts = true, CampaignI3D = 1 });
// OnlyCommissioned
this.SearchReceipts("OnlyCommissioned", new ReceiptSearchFilter { OnlyCommissioned = true });
// ReceiptItemI3D
this.SearchReceipts("ReceiptItemI3D", new ReceiptSearchFilter
{
ReceiptItemI3D = 3378,
ReceiptKinds = new List<CentronObjectKindNumeric>
{
CentronObjectKindNumeric.InvoiceClass
}
});
// ContractKindI3Ds
this.SearchReceipts("ContractKindI3Ds", new ReceiptSearchFilter()
{
ContractKindI3Ds = new List<int>() { 5, 8 }
});
// IsCart
this.SearchReceipts("IsCart_True", new ReceiptSearchFilter
{
IsCart = true,
IncludeClosedReceipts = true, //The one Cart-Offer we have, is closed
}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.True(f.IsCart);
});
});
this.SearchReceipts("IsCart_False", new ReceiptSearchFilter
{
IsCart = false,
IncludeClosedReceipts = true, //The one Cart-Offer we have, is closed
}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
Assert.False(f.IsCart);
});
});
// OnlyNonCarts
this.SearchReceipts("OnlyNonCarts", new ReceiptSearchFilter
{
OnlyNonCarts = true,
IncludeClosedReceipts = true,
}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
if (f.IsCart is true)
{
Assert.Fail("There should be no cart in this list");
}
});
});
// ArticleI3Ds
this.SearchReceipts("ArticleI3Ds", new ReceiptSearchFilter
{
ArticleI3Ds = new List<int> { 149, 1215 }
});
// Search Receipt at one day (special case, because time stamp could break it
// Prepare two receipts with timestamp
base.Sql(@"UPDATE rk SET rk.Datum = '20170214 11:00:00' FROM RechKopf rk WHERE rk.Nummer = 40219;
UPDATE kk SET kk.Datum = '20170214 14:30:00' FROM KalkKopf kk WHERE kk.Nummer = 18070;");
this.SearchReceipts("DateSameDay", new ReceiptSearchFilter
{
DateFrom = new DateTime(2017, 2, 14),
DateTo = new DateTime(2017, 2, 14),
IncludeClosedReceipts = true,
ReceiptKinds = new List<CentronObjectKindNumeric>() { CentronObjectKindNumeric.InvoiceClass, CentronObjectKindNumeric.SupplierInvoice }
}, (filter, receipts) =>
{
Assert.All(receipts, f =>
{
// ReSharper disable once PossibleInvalidOperationException
Assert.True(f.Date.Date == filter.DateFrom.Value.Date);
});
Assert.True(receipts.Count == 4, $"Has ({receipts.Count(f => f.ObjectKind == (int)CentronObjectKindNumeric.InvoiceClass)}/3) customer invoices and ({receipts.Count(f => f.ObjectKind == (int)CentronObjectKindNumeric.SupplierInvoice)}/1) supplier invoice.");
});
// Web-Accounts (all tests should return the same receipts, all for account 10000)
this.SearchReceipts("WebAccount_Default", new ReceiptSearchFilter(), currentUser: this.GetLoggedInUserWebAccount());
this.SearchReceipts("WebAccount_ShouldIgnoreOwnAccountI3DFilter", new ReceiptSearchFilter
{
AccountI3D = 10025,
}, currentUser: this.GetLoggedInUserWebAccount());
this.SearchReceipts("WebAccount_ShouldIgnoreOwnSupplierI3DsFilter", new ReceiptSearchFilter
{
SupplierI3Ds = new List<int> { 70004 },
}, currentUser: this.GetLoggedInUserWebAccount());
//shared documents
this.CreateSharedDocuments();
this.SearchReceipts("Offer_With_SharedDocuments", new ReceiptSearchFilter()
{
ReceiptI3Ds = new List<int>{ 6713,6690},
ReceiptKinds = new List<CentronObjectKindNumeric> { CentronObjectKindNumeric.OfferClass }
});
this.SearchReceipts("Order_With_SharedDocuments", new ReceiptSearchFilter()
{
ReceiptKinds = new List<CentronObjectKindNumeric> { CentronObjectKindNumeric.OrderClass },
ReceiptI3Ds = new List<int>{4382}
});
// IsHiddenInHelpdesk
this.SearchReceipts("IsHiddenInHelpdesk_True", new ReceiptSearchFilter()
{
IsHiddenInHelpdesk = true,
ReceiptKinds = new List<CentronObjectKindNumeric> { CentronObjectKindNumeric.ContractClass }
}, (filter, receipts) =>
{
// All returned contracts should be hidden in helpdesk
Assert.All(receipts, receipt =>
{
Assert.Equal((int)CentronObjectKindNumeric.ContractClass, receipt.ObjectKind);
});
});
this.SearchReceipts("IsHiddenInHelpdesk_False", new ReceiptSearchFilter()
{
IsHiddenInHelpdesk = false,
ReceiptKinds = new List<CentronObjectKindNumeric> { CentronObjectKindNumeric.ContractClass }
}, (filter, receipts) =>
{
// All returned contracts should not be hidden in helpdesk
Assert.All(receipts, receipt =>
{
Assert.Equal((int)CentronObjectKindNumeric.ContractClass, receipt.ObjectKind);
});
});
this.SearchReceipts("IsHiddenInHelpdesk_Null_ContractsOnly", new ReceiptSearchFilter()
{
IsHiddenInHelpdesk = null,
ReceiptKinds = new List<CentronObjectKindNumeric> { CentronObjectKindNumeric.ContractClass }
}, (filter, receipts) =>
{
// Should return all contracts regardless of IsHiddenInHelpdesk value
Assert.All(receipts, receipt =>
{
Assert.Equal((int)CentronObjectKindNumeric.ContractClass, receipt.ObjectKind);
});
});
// Verify IsHiddenInHelpdesk filter only applies to contracts
this.SearchReceipts("IsHiddenInHelpdesk_OnlyAppliesToContracts", new ReceiptSearchFilter()
{
IsHiddenInHelpdesk = true,
ReceiptKinds = new List<CentronObjectKindNumeric>
{
CentronObjectKindNumeric.OfferClass,
CentronObjectKindNumeric.OrderClass,
CentronObjectKindNumeric.InvoiceClass
}
}, (filter, receipts) =>
{
// Should return empty results since IsHiddenInHelpdesk filter doesn't apply to these receipt types
Assert.Empty(receipts);
});
// Only Templates
this.SearchReceipts("OnlyTemplates", new ReceiptSearchFilter()
{
IsReceiptTemplate = true
});
}
private void CreateSharedDocuments()
{
var requestOrder = new GenerateTokenForDocumentRequest()
{
DocumentData = new Byte[] { 65, 100, 125, 86, 107, 90, 68, 188, 69, 81},
DocumentName = "Random Data Order",
ReceiptKind = CentronObjectKindNumeric.OrderClass,
ReceiptI3D = 4382,
};
this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestOrder, GetLoggedInUser().User)).ThrowIfError();
var requestOffer = new GenerateTokenForDocumentRequest()
{
DocumentData = new Byte[] { 58, 250, 33, 202, 234, 181, 55, 146, 122, 111},
DocumentName = "Random Data Offer",
ReceiptKind = CentronObjectKindNumeric.OfferClass,
ReceiptI3D = 6713,
};
var firstOfferSharedDocument = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestOffer, GetLoggedInUser().User)).ThrowIfError();
var requestOffer2 = new GenerateTokenForDocumentRequest()
{
DocumentData = new Byte[] { 239, 34, 192, 40, 119, 53, 162, 94, 254, 251},
DocumentName = "Random Data Offer2",
ReceiptKind = CentronObjectKindNumeric.OfferClass,
ReceiptI3D = 6713,
};
//this should fail, since it would be a second active sharedDocument for the receipt
var failedSharedDocument = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestOffer2, GetLoggedInUser().User));
Assert.Equal(ResultStatus.Error,failedSharedDocument.Status);
//since this the the receipt search test, we don't test the singing method, we simply adjust the entry in the table
this.Sql($"UPDATE SharedDocuments SET IsSigned = 1, State = {(int)SharedDocumentState.EmployeeAcceptanceDeclined} WHERE I3D = {firstOfferSharedDocument.I3D}");
var secondOfferSharedDocument = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestOffer2, GetLoggedInUser().User)).ThrowIfError();
this.Sql($"UPDATE SharedDocuments SET IsSigned = 1, State = {(int)SharedDocumentState.SendToCustomerWaiting} WHERE I3D = {secondOfferSharedDocument.I3D}");
var requestOffer3 = new GenerateTokenForDocumentRequest()
{
DocumentData = new Byte[] { 50, 76, 38, 99, 95, 111, 198, 101, 128, 132},
DocumentName = "Random Data Offer3",
ReceiptKind = CentronObjectKindNumeric.OfferClass,
ReceiptI3D = 6713,
};
this.Sql($"UPDATE SharedDocuments SET IsSigned = 1, State = {(int)SharedDocumentState.EmployeeAcceptanceNotViewed} WHERE I3D = {secondOfferSharedDocument.I3D}");
var thirdSharedDocument = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestOffer3, GetLoggedInUser().User)).ThrowIfError();
this.Sql($"UPDATE SharedDocuments SET State = {(int)SharedDocumentState.SendToCustomerAccepted} WHERE I3D = {thirdSharedDocument.I3D}");
var requestAnotherOffer = new GenerateTokenForDocumentRequest()
{
DocumentData = new Byte[] { 156, 42, 83, 148, 0, 47, 246, 158, 158, 136},
DocumentName = "Random Data Another Offer",
ReceiptKind = CentronObjectKindNumeric.OfferClass,
ReceiptI3D = 6690,
};
var anotherOffer = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GenerateTokenForDocument(requestAnotherOffer, GetLoggedInUser().User)).ThrowIfError();
this.Sql($"UPDATE SharedDocuments SET State = {(int)SharedDocumentState.SendToCustomerWaiting} WHERE I3D = {anotherOffer.I3D}");
}
private void Arrange()
{
using (var session = new BLSession())
{
var saved = session.GetBL<HourlySurchargeRatesWebServiceBL>().SaveHourlySurchargeRate(new HourlySurchargeRateDTO
{
Name = "Mein Satz",
Status = HourlySurchargeRateStatus.Active,
}).ThrowIfError();
this.Sql($"UPDATE dbo.VertragKopf SET HourlySurchargeRateI3D = {saved.I3D} WHERE Nummer = 14035");
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
var savedCampaign = session.GetBL<CampaignWebServiceBL>().SaveCampaign(new LoggedInUser(user), new CampaignDTO
{
Caption = "Erste Kampagne",
Description = "Finde die Kampagne",
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddDays(5),
Participants = new List<CampaignParticipantDTO>(),
State = CampaignStateKind.Open
}).ThrowIfError();
this.Sql($"UPDATE dbo.AngKopf SET CampaignI3D = {savedCampaign.I3D}, IsCart = 1 WHERE Nummer = 10287");
this.Sql("UPDATE dbo.VertragKopf SET IsHiddenInHelpdesk = 1 WHERE I3D IN (21,22,23)");
}
}
private void SearchReceipts(string name, ReceiptSearchFilter filter, Action<ReceiptSearchFilter, IList<ReceiptSearchItemDTO>> validate = null, LoggedInUser currentUser = null)
{
using (var session = new BLSession())
{
var user = currentUser ?? new LoggedInUser(session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11));
var result = session.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(user, filter, 1, int.MaxValue);
this.Verifier.Verify($"Receipts_{name}", result);
validate?.Invoke(filter, result.Data.Result);
var duplicates = result.Data.Result
.GroupBy(f => new { f.ObjectKind, f.Number })
.Where(f => f.Count() > 1)
.ToList();
Assert.Empty(duplicates);
}
}
private void SearchReceiptsWithPaging(string name, ReceiptSearchFilter filter)
{
var actual = new List<ReceiptSearchItemDTO>();
int currentPage = 1;
while (true)
{
using (var session = new BLSession())
{
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
var result = session.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, currentPage, 10);
if (result.Data.Result.Count == 0)
break;
actual.AddRange(result.Data.Result);
currentPage++;
}
}
using (var session = new BLSession())
{
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
var expected = session.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, 1, int.MaxValue);
Assert.Equal(expected.Data.Result.Select(f => f.Number), actual.Select(f => f.Number));
}
}
}
}