2021-07-13 05:35:31 +00:00
|
|
|
using Props.Shop.Framework;
|
2021-04-23 20:11:49 +00:00
|
|
|
using SimpleLogger;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
2021-07-13 05:35:31 +00:00
|
|
|
namespace Props.Shop.AliExpressModule.Tests
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
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()
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
//Given
|
2021-05-09 06:49:37 +00:00
|
|
|
const int MAX_RESULTS = 120;
|
2021-04-23 20:11:49 +00:00
|
|
|
Shop shop = new Shop();
|
2021-05-09 06:49:37 +00:00
|
|
|
shop.UseProxy = false;
|
|
|
|
shop.Initialize();
|
2021-04-23 20:11:49 +00:00
|
|
|
//When
|
2021-05-09 06:49:37 +00:00
|
|
|
shop.SetupSession("mpu6050", Currency.CAD);
|
2021-04-23 20:11:49 +00:00
|
|
|
//Then
|
2021-05-09 06:49:37 +00:00
|
|
|
int count = 0;
|
|
|
|
await foreach (ProductListing listing in shop)
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
2021-05-09 06:49:37 +00:00
|
|
|
count += 1;
|
|
|
|
if (count > MAX_RESULTS) return;
|
2021-04-23 20:11:49 +00:00
|
|
|
}
|
2021-05-11 06:52:57 +00:00
|
|
|
shop.Dispose();
|
2021-04-23 20:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2021-05-09 06:49:37 +00:00
|
|
|
public async void Search_USD_ResultsFound()
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
//Given
|
2021-05-09 06:49:37 +00:00
|
|
|
const int MAX_RESULTS = 120;
|
2021-04-23 20:11:49 +00:00
|
|
|
Shop shop = new Shop();
|
2021-05-09 06:49:37 +00:00
|
|
|
shop.UseProxy = false;
|
|
|
|
shop.Initialize();
|
2021-04-23 20:11:49 +00:00
|
|
|
//When
|
2021-05-09 06:49:37 +00:00
|
|
|
shop.SetupSession("mpu6050", Currency.USD);
|
2021-04-23 20:11:49 +00:00
|
|
|
//Then
|
2021-05-09 06:49:37 +00:00
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
await foreach (ProductListing listing in shop)
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
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-04-23 20:11:49 +00:00
|
|
|
}
|
2021-05-11 06:52:57 +00:00
|
|
|
shop.Dispose();
|
2021-04-23 20:11:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|