props/test/AliExpressShop.Tests/ShopTest.cs

63 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2021-05-09 06:49:37 +00:00
using System.Threading;
using System.Threading.Tasks;
using GameServiceWarden.Core.Tests;
using MultiShop.ShopFramework;
using SimpleLogger;
using Xunit;
using Xunit.Abstractions;
namespace AliExpressShop.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;
}
}
[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;
}
}
}
}