diff --git a/test/BraunauMobil.VeloBasar.DataGenerator/Program.cs b/test/BraunauMobil.VeloBasar.DataGenerator/Program.cs index 7f917d4..7677261 100644 --- a/test/BraunauMobil.VeloBasar.DataGenerator/Program.cs +++ b/test/BraunauMobil.VeloBasar.DataGenerator/Program.cs @@ -10,7 +10,9 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using System.Diagnostics; using System.Globalization; +using System.Text; using Xan.Extensions; namespace BraunauMobil.VeloBasar.DataGenerator; @@ -22,8 +24,102 @@ public static async Task Main() CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); + Random rand = new(); - await GeneratePostgresAsync("User ID=postgres;Password=postgres;Host=localhost;Port=5432;Database=velobasar;Pooling=true;"); + StringBuilder sb = new(); + + sb.AppendLine("Sellers"); + sb.AppendLine(); + + string[] countries = ["Austria", "Germany"]; + + foreach (var x in Enumerable.Range(0, 8)) + { + string firstName = rand.GetRandomElement(Names.FirstNames); + string lastName = rand.GetRandomElement(Names.FirstNames); + sb.AppendLine($"{{ \"BankAccountHolder\", \"{firstName} {firstName[0]}.{lastName[0]}. {lastName}\" }},"); + sb.AppendLine($"{{ \"City\", \"{rand.GetRandomElement(Names.Cities)}\" }},"); + sb.AppendLine($"{{ \"CountryId\", ID.Countries.{rand.GetRandomElement(countries)} }},"); + sb.AppendLine($"{{ \"EMail\", \"{firstName.ToLower().Replace(" ", "")}@{lastName.ToLower().Replace(" ", "")}.me\" }},"); + sb.AppendLine($"{{ \"FirstName\", \"{firstName}\" }},"); + sb.AppendLine($"{{ \"HasNewsletterPermission\", {(rand.Next(0, 2) == 0).ToString().ToLower()} }},"); + sb.AppendLine("{ \"IBAN\", \"\" },"); + sb.AppendLine($"{{ \"LastName\", \"{lastName}\" }},"); + sb.AppendLine($"{{ \"Street\", \"{rand.GetRandomElement(Names.Streets)} {rand.Next(1, 50)}\" }},"); + sb.Append("{ \"PhoneNumber\", \""); + for (int counter = 0; counter < rand.Next(8, 11); counter++) + { + sb.Append(rand.Next(0, 10)); + } + sb.AppendLine("\" },"); + sb.AppendLine($"{{ \"ZIP\", \"{rand.Next(1, 10)}{rand.Next(1, 10)}{rand.Next(1, 10)}{rand.Next(1, 10)}\" }},"); + + sb.AppendLine(); + } + + sb.AppendLine("--------------------------------------------------------------------------"); + sb.AppendLine("Products"); + sb.AppendLine(); + + + string[] typeNames = [ + "Unicycle", + "RoadBike", + "MansCityBike", + "WomansCityBike", + "ChildrensBike", + "Scooter", + "EBike", + "SteelSteed", + ]; + string[] colors = [ + "red", + "blue", + "green", + "yellow", + "orange", + "purple", + "pink", + "brown", + "gray", + "turquoise", + "lavender", + "maroon", + "indigo", + "cyan", + "olive", + "peach", + "teal", + "magenta", + "beige", + "slate", + ]; + + foreach (var x in Enumerable.Range(0, 30)) + { + string brand = rand.GetRandomElement(Names.BrandNames); + sb.AppendLine($"{{ \"TypeId\", ID.ProductTypes.{rand.GetRandomElement(typeNames)} }},"); + sb.AppendLine($"{{ \"Brand\", \"{brand}\" }},"); + sb.AppendLine($"{{ \"Color\", \"{rand.GetRandomElement(colors)}\" }},"); + if (rand.Next(0, 2) == 0) + { + sb.AppendLine($"{{ \"FrameNumber\", \"{Guid.NewGuid().ToString()[..rand.Next(7, 10)]}\" }},"); + } + sb.AppendLine($"{{ \"Description\", \"{brand[..].ToUpper()}_{rand.Next(10000, 999999)}\" }},"); + sb.AppendLine($"{{ \"TireSize\", \"{rand.GetRandomElement(Names.TireSizes)}\" }},"); + sb.AppendLine($"{{ \"Price\", {Math.Round((decimal)rand.GetGaussian(100, 50), 2)}M }},"); + sb.AppendLine(); + } + + string fileName = @"c:\temp\testData.txt"; + File.WriteAllText(fileName, sb.ToString()); + ProcessStartInfo info = new(fileName) + { + UseShellExecute = true + }; + Process.Start(info); + + //await GeneratePostgresAsync("User ID=postgres;Password=postgres;Host=localhost;Port=5432;Database=velobasar;Pooling=true;"); } private static async Task GeneratePostgresAsync(string connectionString) diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/ID.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/ID.cs index abbe320..3fd991a 100644 --- a/test/BraunauMobil.VeloBasar.IntegrationTests/ID.cs +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/ID.cs @@ -28,6 +28,8 @@ public static class Sellers public const int SchattenfellMagsame = 1; public const int MeneldorBorondir = 2; public const int AmrothGerstenmann = 3; + public const int LanghöhlenSiriondil = 4; + public const int FrórBilbo = 5; } public static class Products diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/FirstBasar/AcceptSellers.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/FirstBasar/AcceptSellers.cs index ed7a50b..0666e2c 100644 --- a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/FirstBasar/AcceptSellers.cs +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/FirstBasar/AcceptSellers.cs @@ -11,6 +11,8 @@ public async Task Run() private async Task AcceptSeller1(TestContext context) { + const string expectedTitle = "Acceptance for seller with ID: 1 - Enter products - Velo Basar"; + IHtmlDocument newAcceptanceDocument = await context.HttpClient.NavigateMenuAsync("New Acceptance"); newAcceptanceDocument.Title.Should().Be("Acceptance - Enter seller - Velo Basar"); @@ -28,10 +30,28 @@ private async Task AcceptSeller1(TestContext context) { "PhoneNumber", "71904814" }, { "EMail", "schattenfell@magsame.me" }, }); - enterProductsDocument.Title.Should().Be("Acceptance for seller with ID: 1 - Enter products - Velo Basar"); + enterProductsDocument.Title.Should().Be(expectedTitle); - enterProductsDocument = await EnterProduct1(enterProductsDocument); - enterProductsDocument = await EnterProduct2(enterProductsDocument); + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.ChildrensBike }, + { "Brand", "Votec" }, + { "Color", "green" }, + { "FrameNumber", "1067425379" }, + { "Description", "Votec VRC Comp" }, + { "TireSize", "24" }, + { "Price", 92.99m } + }); + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.SteelSteed }, + { "Brand", "KTM" }, + { "Color", "red" }, + { "FrameNumber", "1239209209" }, + { "Description", "Steed 1" }, + { "TireSize", "22" }, + { "Price", 98.89m } + }); IHtmlAnchorElement saveAnchor = enterProductsDocument.QueryAnchorByText("Save accept session"); @@ -56,44 +76,6 @@ private async Task AcceptSeller1(TestContext context) ); } - private async Task EnterProduct1(IHtmlDocument enterProductsDocument) - { - IHtmlFormElement form = enterProductsDocument.QueryForm(); - IHtmlButtonElement submitButton = enterProductsDocument.QueryButtonByText("Add"); - - IHtmlDocument postDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary - { - { "TypeId", ID.ProductTypes.ChildrensBike }, - { "Brand", "Votec" }, - { "Color", "green" }, - { "FrameNumber", "1067425379" }, - { "Description", "Votec VRC Comp" }, - { "TireSize", "24" }, - { "Price", 92.99m } - }); - postDocument.Title.Should().Be("Acceptance for seller with ID: 1 - Enter products - Velo Basar"); - return postDocument; - } - - private async Task EnterProduct2(IHtmlDocument enterProductsDocument) - { - IHtmlFormElement form = enterProductsDocument.QueryForm(); - IHtmlButtonElement submitButton = enterProductsDocument.QueryButtonByText("Add"); - - IHtmlDocument postDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary - { - { "TypeId", ID.ProductTypes.SteelSteed }, - { "Brand", "KTM" }, - { "Color", "red" }, - { "FrameNumber", "1239209209" }, - { "Description", "Steed 1" }, - { "TireSize", "22" }, - { "Price", 98.89m } - }); - postDocument.Title.Should().Be("Acceptance for seller with ID: 1 - Enter products - Velo Basar"); - return postDocument; - } - private async Task AssertBasarDetails() { BasarSettlementStatus basarSettlementStatus = new(false, diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/AcceptSellers.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/AcceptSellers.cs new file mode 100644 index 0000000..8f9bc8e --- /dev/null +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/AcceptSellers.cs @@ -0,0 +1,66 @@ +namespace BraunauMobil.VeloBasar.IntegrationTests.Steps.SecondBasar.AcceptSellers; + +public class AcceptSellers(TestContext context) +{ + public async Task Run() + { + await new Seller2_AcceptAndThenAcceptViaDetails(context).Run(); + await new Seller3_CancelOnEnterProducts(context).Run(); + await new Seller4(context).Run(); + await new Seller5(context).Run(); + + await AssertBasarDetails(); + } + + private async Task AssertBasarDetails() + { + BasarSettlementStatus basarSettlementStatus = new(false, + new SellerGroupSettlementStatus(3, 0), + new SellerGroupSettlementStatus(3, 0), + new SellerGroupSettlementStatus(0, 0) + ); + BasarDetailsModel expectedDetails = new(new BasarEntity(), basarSettlementStatus) + { + AcceptanceCount = 4, + AcceptedProductsAmount = 909.35M, + AcceptedProductsCount = 9, + AcceptedProductTypesByAmount = [ + new ChartDataPoint(96.81M, "Scooter", X.AnyColor), + new ChartDataPoint(69.54M, "E-bike", X.AnyColor), + new ChartDataPoint(117.48M, "Road bike", X.AnyColor), + new ChartDataPoint(151.34M, "Steel steed", X.AnyColor), + new ChartDataPoint(183.53M, "Men's city bike", X.AnyColor), + new ChartDataPoint(183.90M, "Woman's city bike", X.AnyColor), + new ChartDataPoint(106.75M, "Unicycle", X.AnyColor), + ], + AcceptedProductTypesByCount = [ + new ChartDataPoint(2, "Scooter", X.AnyColor), + new ChartDataPoint(1, "E-bike", X.AnyColor), + new ChartDataPoint(1, "Road bike", X.AnyColor), + new ChartDataPoint(1, "Steel steed", X.AnyColor), + new ChartDataPoint(1, "Men's city bike", X.AnyColor), + new ChartDataPoint(2, "Woman's city bike", X.AnyColor), + new ChartDataPoint(1, "Unicycle", X.AnyColor), + ], + LockedProductsCount = 0, + LostProductsCount = 0, + PriceDistribution = [ + new ChartDataPoint(1, "$50.00", X.AnyColor), + new ChartDataPoint(1, "$60.00", X.AnyColor), + new ChartDataPoint(2, "$70.00", X.AnyColor), + new ChartDataPoint(1, "$110.00", X.AnyColor), + new ChartDataPoint(2, "$120.00", X.AnyColor), + new ChartDataPoint(1, "$160.00", X.AnyColor), + new ChartDataPoint(1, "$190.00", X.AnyColor), + ], + SaleCount = 0, + SaleDistribution = [], + SoldProductsAmount = 0, + SoldProductsCount = 0, + SoldProductTypesByCount = [], + SoldProductTypesByAmount = [], + }; + + await context.AssertBasarDetails(ID.SecondBasar, expectedDetails); + } +} diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller2_AcceptAndThenAcceptViaDetails.cs similarity index 53% rename from test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers.cs rename to test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller2_AcceptAndThenAcceptViaDetails.cs index 56c780a..7eeafe9 100644 --- a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers.cs +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller2_AcceptAndThenAcceptViaDetails.cs @@ -1,15 +1,8 @@ namespace BraunauMobil.VeloBasar.IntegrationTests.Steps.SecondBasar; -public class AcceptSellers(TestContext context) +public class Seller2_AcceptAndThenAcceptViaDetails(TestContext context) { public async Task Run() - { - await Seller2_AcceptAndThenAcceptViaDetails(); - await Seller3_CancelOnEnterProducts(); - await AssertBasarDetails(); - } - - private async Task Seller2_AcceptAndThenAcceptViaDetails() { const string expectedTitle = "Acceptance for seller with ID: 2 - Enter products - Velo Basar"; @@ -33,7 +26,7 @@ private async Task Seller2_AcceptAndThenAcceptViaDetails() }); enterProductsDocument.Title.Should().Be(expectedTitle); - enterProductsDocument = await EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary { { "TypeId", ID.ProductTypes.Scooter }, { "Brand", "Additive" }, @@ -43,7 +36,7 @@ private async Task Seller2_AcceptAndThenAcceptViaDetails() { "TireSize", "16" }, { "Price", 51.06m } }); - enterProductsDocument = await EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary { { "TypeId", ID.ProductTypes.Scooter }, { "Brand", "Toxy" }, @@ -85,7 +78,7 @@ private async Task Seller2_AcceptAndThenAcceptViaDetails() IHtmlAnchorElement acceptProductsAnchor = sellerDetailsDocument.QueryAnchorByText("Accept products"); enterProductsDocument = await context.HttpClient.GetDocumentAsync(acceptProductsAnchor.Href); - enterProductsDocument = await EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary { { "TypeId", ID.ProductTypes.EBike }, { "Brand", "Draisin" }, @@ -94,7 +87,7 @@ private async Task Seller2_AcceptAndThenAcceptViaDetails() { "TireSize", "23" }, { "Price", 69.54M } }); - enterProductsDocument = await EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary { { "TypeId", ID.ProductTypes.RoadBike }, { "Brand", "Cyclecraft" }, @@ -137,96 +130,4 @@ private async Task Seller2_AcceptAndThenAcceptViaDetails() }; await context.AssertSellerDetails(ID.SecondBasar, ID.Sellers.MeneldorBorondir, expectedDetails); } - - private async Task Seller3_CancelOnEnterProducts() - { - const string expectedTitle = "Acceptance for seller with ID: 3 - Enter products - Velo Basar"; - - IHtmlDocument newAcceptanceDocument = await context.HttpClient.NavigateMenuAsync("New Acceptance"); - newAcceptanceDocument.Title.Should().Be("Acceptance - Enter seller - Velo Basar"); - - IHtmlFormElement form = newAcceptanceDocument.QueryForm(); - IHtmlButtonElement submitButton = newAcceptanceDocument.QueryButtonByText("Continue"); - - IHtmlDocument enterProductsDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary - { - { "FirstName", "Amroth" }, - { "LastName", "Gerstenmann" }, - { "CountryId", ID.Countries.Austria }, - { "ZIP", "7872" }, - { "City", "Dwollingen" }, - { "Street", "Concordiaplatz 48" }, - { "PhoneNumber", "161606605" }, - { "EMail", "amroth@gerstenmann.me" }, - { "HasNewsletterPermission", true }, - }); - enterProductsDocument.Title.Should().Be(expectedTitle); - - IHtmlAnchorElement cancelAnchor = enterProductsDocument.QueryAnchorByText("Cancel"); - IHtmlDocument sellerDetailsDocument = await context.HttpClient.GetDocumentAsync(cancelAnchor.Href); - sellerDetailsDocument.Title.Should().Be("Seller #3 Amroth Gerstenmann - Velo Basar"); - - SellerDetailsModel expectedDetails = new (new SellerEntity()) - { - AcceptedProductCount = 0, - NotSoldProductCount = 0, - PickedUpProductCount = 0, - Products = [], - SettlementAmout = 0, - SoldProductCount = 0, - Transactions = [] - }; - await context.AssertSellerDetails(ID.SecondBasar, ID.Sellers.AmrothGerstenmann, expectedDetails); - } - - private async Task AssertBasarDetails() - { - BasarSettlementStatus basarSettlementStatus = new(false, - new SellerGroupSettlementStatus(1, 0), - new SellerGroupSettlementStatus(1, 0), - new SellerGroupSettlementStatus(0, 0) - ); - BasarDetailsModel expectedDetails = new(new BasarEntity(), basarSettlementStatus) - { - AcceptanceCount = 2, - AcceptedProductsAmount = 283.83M, - AcceptedProductsCount = 4, - AcceptedProductTypesByAmount = [ - new ChartDataPoint(96.81M, "Scooter", X.AnyColor), - new ChartDataPoint(69.54M, "E-bike", X.AnyColor), - new ChartDataPoint(117.48M, "Road bike", X.AnyColor) - ], - AcceptedProductTypesByCount = [ - new ChartDataPoint(2, "Scooter", X.AnyColor), - new ChartDataPoint(1, "E-bike", X.AnyColor), - new ChartDataPoint(1, "Road bike", X.AnyColor) - ], - LockedProductsCount = 0, - LostProductsCount = 0, - PriceDistribution = [ - new ChartDataPoint(1, "$50.00", X.AnyColor), - new ChartDataPoint(1, "$60.00", X.AnyColor), - new ChartDataPoint(1, "$70.00", X.AnyColor), - new ChartDataPoint(1, "$120.00", X.AnyColor) - ], - SaleCount = 0, - SaleDistribution = [], - SoldProductsAmount = 0, - SoldProductsCount = 0, - SoldProductTypesByCount = [], - SoldProductTypesByAmount = [], - }; - - await context.AssertBasarDetails(ID.SecondBasar, expectedDetails); - } - - private async Task EnterProduct(IHtmlDocument enterProductsDocument, string expectedTitle, IDictionary values) - { - IHtmlFormElement form = enterProductsDocument.QueryForm(); - IHtmlButtonElement submitButton = enterProductsDocument.QueryButtonByText("Add"); - - IHtmlDocument postDocument = await context.HttpClient.SendFormAsync(form, submitButton, values); - postDocument.Title.Should().Be(expectedTitle); - return postDocument; - } } diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller3_CancelOnEnterProducts.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller3_CancelOnEnterProducts.cs new file mode 100644 index 0000000..c3e5bb6 --- /dev/null +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller3_CancelOnEnterProducts.cs @@ -0,0 +1,43 @@ +namespace BraunauMobil.VeloBasar.IntegrationTests.Steps.SecondBasar; + +public class Seller3_CancelOnEnterProducts(TestContext context) +{ + public async Task Run() + { + const string expectedTitle = "Acceptance for seller with ID: 3 - Enter products - Velo Basar"; + + IHtmlDocument newAcceptanceDocument = await context.HttpClient.NavigateMenuAsync("New Acceptance"); + newAcceptanceDocument.Title.Should().Be("Acceptance - Enter seller - Velo Basar"); + + IHtmlFormElement form = newAcceptanceDocument.QueryForm(); + IHtmlButtonElement submitButton = newAcceptanceDocument.QueryButtonByText("Continue"); + + IHtmlDocument enterProductsDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary + { + { "FirstName", "Amroth" }, + { "LastName", "Gerstenmann" }, + { "CountryId", ID.Countries.Austria }, + { "ZIP", "7872" }, + { "City", "Dwollingen" }, + { "Street", "Concordiaplatz 48" }, + { "PhoneNumber", "161606605" }, + { "EMail", "amroth@gerstenmann.me" }, + { "HasNewsletterPermission", true }, + }); + enterProductsDocument.Title.Should().Be(expectedTitle); + + IHtmlAnchorElement cancelAnchor = enterProductsDocument.QueryAnchorByText("Cancel"); + IHtmlDocument sellerDetailsDocument = await context.HttpClient.GetDocumentAsync(cancelAnchor.Href); + sellerDetailsDocument.Title.Should().Be("Seller #3 Amroth Gerstenmann - Velo Basar"); + + SellerDetailsModel expectedDetails = new (new SellerEntity()) + { + AcceptedProductCount = 0, + NotSoldProductCount = 0, + PickedUpProductCount = 0, + SettlementAmout = 0, + SoldProductCount = 0 + }; + await context.AssertSellerDetails(ID.SecondBasar, ID.Sellers.AmrothGerstenmann, expectedDetails); + } +} diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller4.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller4.cs new file mode 100644 index 0000000..a329faf --- /dev/null +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller4.cs @@ -0,0 +1,72 @@ +namespace BraunauMobil.VeloBasar.IntegrationTests.Steps.SecondBasar; + +public class Seller4(TestContext context) +{ + public async Task Run() + { + const string expectedTitle = "Acceptance for seller with ID: 4 - Enter products - Velo Basar"; + + IHtmlDocument newAcceptanceDocument = await context.HttpClient.NavigateMenuAsync("New Acceptance"); + newAcceptanceDocument.Title.Should().Be("Acceptance - Enter seller - Velo Basar"); + + IHtmlFormElement form = newAcceptanceDocument.QueryForm(); + IHtmlButtonElement submitButton = newAcceptanceDocument.QueryButtonByText("Continue"); + + IHtmlDocument enterProductsDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary + { + { "FirstName", "Langhöhlen" }, + { "LastName", "Siriondil" }, + { "CountryId", ID.Countries.Germany }, + { "ZIP", "2178" }, + { "City", "Nargothrond" }, + { "Street", "Börseplatz 11" }, + { "PhoneNumber", "74460686" }, + { "EMail", "langhoehlen@siriondil.me" }, + { "HasNewsletterPermission", false }, + }); + enterProductsDocument.Title.Should().Be(expectedTitle); + + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.WomansCityBike }, + { "Brand", "Epple" }, + { "Color", "white" }, + { "FrameNumber", "G#%$BIBM#$)" }, + { "Description", "No tires" }, + { "TireSize", "22" }, + { "Price", 69.54m } + }); + + IHtmlAnchorElement saveAnchor = enterProductsDocument.QueryAnchorByText("Save accept session"); + + IHtmlDocument successDocument = await context.HttpClient.GetDocumentAsync(saveAnchor.Href); + successDocument.Title.Should().Be("Acceptance #3 - Velo Basar"); + + IHtmlAnchorElement voucherAnchor = successDocument.QueryAnchorByText("Voucher"); + AcceptanceDocumentModel document = await context.HttpClient.GetAcceptanceDocumentAsync(voucherAnchor.Href); + document.Should().BeEquivalentTo(context.AcceptanceDocument("XYZ - Second Bazaar : Acceptance receipt #3", + "Thal, 6/4/2064", + "Langhöhlen Siriondil".Line("Börseplatz 11").Line("2178 Nargothrond").Line(), + "Seller.-ID: 4", + "statusLink=4C6145369", + "4C6145369", + "Thal on Tuesday, May 6, 2064 at 12:23 PM", + "1 Product", + "$69.54", + [ + new ProductTableRowDocumentModel("7", "Epple - Woman's city bike".Line("No tires").Line(" white G#%$BIBM#$)"), "22", "$69.54", null) + ]) + ); + + SellerDetailsModel expectedDetails = new (new SellerEntity()) + { + AcceptedProductCount = 1, + NotSoldProductCount = 1, + PickedUpProductCount = 0, + SettlementAmout = 0, + SoldProductCount = 0, + Transactions = [] + }; + await context.AssertSellerDetails(ID.SecondBasar, ID.Sellers.LanghöhlenSiriondil, expectedDetails); + } +} diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller5.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller5.cs new file mode 100644 index 0000000..632b970 --- /dev/null +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/Steps/SecondBasar/AcceptSellers/Seller5.cs @@ -0,0 +1,104 @@ +namespace BraunauMobil.VeloBasar.IntegrationTests.Steps.SecondBasar; + +public class Seller5(TestContext context) +{ + public async Task Run() + { + const string expectedTitle = "Acceptance for seller with ID: 5 - Enter products - Velo Basar"; + + IHtmlDocument newAcceptanceDocument = await context.HttpClient.NavigateMenuAsync("New Acceptance"); + newAcceptanceDocument.Title.Should().Be("Acceptance - Enter seller - Velo Basar"); + + IHtmlFormElement form = newAcceptanceDocument.QueryForm(); + IHtmlButtonElement submitButton = newAcceptanceDocument.QueryButtonByText("Continue"); + + IHtmlDocument enterProductsDocument = await context.HttpClient.SendFormAsync(form, submitButton, new Dictionary + { + { "BankAccountHolder", "Frór F.B. Bilbo" }, + { "City", "Andúnië" }, + { "CountryId", ID.Countries.Germany }, + { "EMail", "fror@bilbo.me" }, + { "FirstName", "Frór" }, + { "HasNewsletterPermission", false }, + { "LastName", "Bilbo" }, + { "Street", "Helmut-Zilk-Platz 27" }, + { "PhoneNumber", "14712192" }, + { "ZIP", "8475" }, + }); + enterProductsDocument.Title.Should().Be(expectedTitle); + + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.SteelSteed }, + { "Brand", "Pedalpower" }, + { "Color", "gray" }, + { "FrameNumber", "95f7-4ba0-94b6-6c45a1cd0913" }, + { "Description", "VOSS SPEZIALRAD_465693" }, + { "TireSize", "16" }, + { "Price", 151.34M }, + }); + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.MansCityBike }, + { "Brand", "Egon Rahe" }, + { "Color", "maroon" }, + { "Description", "VELOMOBILES_92370" }, + { "TireSize", "20" }, + { "Price", 183.53M }, + }); + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.Unicycle }, + { "Brand", "Seidel & Naumann" }, + { "Color", "lavender" }, + { "Description", "SALIKO_52513" }, + { "TireSize", "14" }, + { "Price", 106.75M }, + }); + enterProductsDocument = await context.EnterProduct(enterProductsDocument, expectedTitle, new Dictionary + { + { "TypeId", ID.ProductTypes.WomansCityBike }, + { "Brand", "Leiba" }, + { "Color", "maroon" }, + { "FrameNumber", "1b26-4d44-94fe-027810ef43e7" }, + { "Description", "MIELE_398047" }, + { "TireSize", "17" }, + { "Price", 114.36M }, + }); + + IHtmlAnchorElement saveAnchor = enterProductsDocument.QueryAnchorByText("Save accept session"); + + IHtmlDocument successDocument = await context.HttpClient.GetDocumentAsync(saveAnchor.Href); + successDocument.Title.Should().Be("Acceptance #4 - Velo Basar"); + + IHtmlAnchorElement voucherAnchor = successDocument.QueryAnchorByText("Voucher"); + AcceptanceDocumentModel document = await context.HttpClient.GetAcceptanceDocumentAsync(voucherAnchor.Href); + document.Should().BeEquivalentTo(context.AcceptanceDocument("XYZ - Second Bazaar : Acceptance receipt #4", + "Thal, 6/4/2064", + "Frór Bilbo".Line("Helmut-Zilk-Platz 27").Line("8475 Andúnië").Line(), + "Seller.-ID: 5", + "statusLink=467254269", + "467254269", + "Thal on Tuesday, May 6, 2064 at 12:23 PM", + "4 Product", + "$555.98", + [ + new ProductTableRowDocumentModel("8", "Pedalpower - Steel steed".Line("VOSS SPEZIALRAD_465693").Line(" gray 95f7-4ba0-94b6-6c45a1cd0913"), "16", "$151.34", null), + new ProductTableRowDocumentModel("9", "Egon Rahe - Men's city bike".Line("VELOMOBILES_92370").Line(" maroon"), "20", "$183.53", null), + new ProductTableRowDocumentModel("10", "Seidel & Naumann - Unicycle".Line("SALIKO_52513").Line(" lavender"), "14", "$106.75", null), + new ProductTableRowDocumentModel("11", "Leiba - Woman's city bike".Line("MIELE_398047").Line(" maroon 1b26-4d44-94fe-027810ef43e7"), "17", "$114.36", null) + ]) + ); + + SellerDetailsModel expectedDetails = new (new SellerEntity()) + { + AcceptedProductCount = 4, + NotSoldProductCount = 4, + PickedUpProductCount = 0, + SettlementAmout = 0, + SoldProductCount = 0, + Transactions = [] + }; + await context.AssertSellerDetails(ID.SecondBasar, ID.Sellers.FrórBilbo, expectedDetails); + } +} diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/TestContext.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/TestContext.cs index f6549d1..396667c 100644 --- a/test/BraunauMobil.VeloBasar.IntegrationTests/TestContext.cs +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/TestContext.cs @@ -97,6 +97,20 @@ public string BankingQrCode(string seller, string amount, string decscription) .Line(); } + public async Task EnterProduct(IHtmlDocument enterProductsDocument, string expectedTitle, IDictionary values) + { + ArgumentNullException.ThrowIfNull(enterProductsDocument); + ArgumentNullException.ThrowIfNull(expectedTitle); + ArgumentNullException.ThrowIfNull(values); + + IHtmlFormElement form = enterProductsDocument.QueryForm(); + IHtmlButtonElement submitButton = enterProductsDocument.QueryButtonByText("Add"); + + IHtmlDocument postDocument = await HttpClient.SendFormAsync(form, submitButton, values); + postDocument.Title.Should().Be(expectedTitle); + return postDocument; + } + public SaleDocumentModel SaleDocument(string title, string locationAndDateText, string productTableCountText, string productTablePriceText, IReadOnlyCollection productTableRows) => new(title, locationAndDateText, diff --git a/test/BraunauMobil.VeloBasar.IntegrationTests/VeloBasarTest.cs b/test/BraunauMobil.VeloBasar.IntegrationTests/VeloBasarTest.cs index af58bc6..4b8f283 100644 --- a/test/BraunauMobil.VeloBasar.IntegrationTests/VeloBasarTest.cs +++ b/test/BraunauMobil.VeloBasar.IntegrationTests/VeloBasarTest.cs @@ -31,7 +31,7 @@ public async Task Run() X.Clock.Now = X.FirstContactDay.AddYears(1).AddMonths(1).AddDays(1).AddHours(1).AddMinutes(1).AddSeconds(1); await new Steps.SecondBasar.Creation(_context).Run(); - await new Steps.SecondBasar.AcceptSellers(_context).Run(); + await new Steps.SecondBasar.AcceptSellers.AcceptSellers(_context).Run(); }