props/MultiShop-Modules/test/MultiShop.Shop/AliExpressModule.Tests/ShopTest.cs

60 lines
1.6 KiB
C#
Raw Normal View History

using MultiShop.Shop.Framework;
using SimpleLogger;
using Xunit;
using Xunit.Abstractions;
namespace MultiShop.Shop.AliExpressModule.Tests
{
public class ShopTest
{
public ShopTest(ITestOutputHelper output)
{
Logger.AddLogListener(new XUnitLogger(output));
}
[Fact]
2021-05-09 06:49:37 +00:00
public async void Search_SearchForItem_MultiplePages()
{
//Given
2021-05-09 06:49:37 +00:00
const int MAX_RESULTS = 120;
Shop shop = new Shop();
2021-05-09 06:49:37 +00:00
shop.UseProxy = false;
shop.Initialize();
//When
2021-05-09 06:49:37 +00:00
shop.SetupSession("mpu6050", Currency.CAD);
//Then
2021-05-09 06:49:37 +00:00
int count = 0;
await foreach (ProductListing listing in shop)
{
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
2021-05-09 06:49:37 +00:00
count += 1;
if (count > MAX_RESULTS) return;
}
2021-05-11 06:52:57 +00:00
shop.Dispose();
}
[Fact]
2021-05-09 06:49:37 +00:00
public async void Search_USD_ResultsFound()
{
//Given
2021-05-09 06:49:37 +00:00
const int MAX_RESULTS = 120;
Shop shop = new Shop();
2021-05-09 06:49:37 +00:00
shop.UseProxy = false;
shop.Initialize();
//When
2021-05-09 06:49:37 +00:00
shop.SetupSession("mpu6050", Currency.USD);
//Then
2021-05-09 06:49:37 +00:00
int count = 0;
await foreach (ProductListing listing in shop)
{
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
Assert.True(listing.LowerPrice != 0);
2021-05-09 06:49:37 +00:00
count += 1;
if (count > MAX_RESULTS) return;
}
2021-05-11 06:52:57 +00:00
shop.Dispose();
}
}
}