using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.Warehousing; using Centron.BusinessLogic.WebServices.Employee; using Centron.BusinessLogic.WebServices.Warehousing; using Centron.Data.Entities.Merchandise.Articles; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Administration.Employees; public class EmployeeArticleParentTests : EndToEndTest { public EmployeeArticleParentTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { using (var session = new BLSession()) { // Test case 1: Set article with the I3D 11 to have a parent article with I3D 14 var article = session.GetBL().GetArticleByArticleI3D(11); article.ParentArticleI3D = 14; var saveResult = session.GetBL().SaveArticle(article, base.GetLoggedInUser()); Assert.True(saveResult.Status == ResultStatus.Success, saveResult.Message); // Test case 2: Check if we get the article with I3D 11 when searching for articles with parent article I3D 14 from Employee with I3D 14 var bl = session.GetBL(); var searchResult = bl.GetEmployeeArticlesAsArticle(new EmployeeArticleFilter() { EmployeeI3D = 25, ParentArticleI3D = 14 }, base.GetLoggedInUser().User); Assert.True(searchResult.FirstOrDefault()?.I3D == 11, $"Expected article with I3D 11, but found: {searchResult.FirstOrDefault()?.I3D}"); // Test case 3 : Check if we can retrieve the parent article of article with I3D 11 var articleBL = session.GetBL(); var articleSearchResult = articleBL.GetArticlesThroughPaging(ArticlePreviewSort.ArticleCode, false, new ArticleCompactFilter() { IsParentArticle = true }, 1, 100); Assert.True(articleSearchResult.Result.First().I3D == 14, $"Expected parent article with I3D 14, but found: {articleSearchResult.Result.First().I3D}"); } } }