Added Banggood shop.

This commit is contained in:
2021-05-11 01:52:57 -05:00
parent 04d4caf2bd
commit e675962c35
14 changed files with 302 additions and 16 deletions

View File

@@ -1,7 +1,3 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GameServiceWarden.Core.Tests;
using MultiShop.ShopFramework;
using SimpleLogger;
using Xunit;
@@ -34,10 +30,10 @@ namespace AliExpressShop.Tests
count += 1;
if (count > MAX_RESULTS) return;
}
shop.Dispose();
}
[Fact]
public async void Search_USD_ResultsFound()
{
//Given
@@ -57,6 +53,7 @@ namespace AliExpressShop.Tests
count += 1;
if (count > MAX_RESULTS) return;
}
shop.Dispose();
}
}
}

View File

@@ -2,7 +2,7 @@ using System;
using SimpleLogger;
using Xunit.Abstractions;
namespace GameServiceWarden.Core.Tests
namespace AliExpressShop
{
public class XUnitLogger : ILogReceiver
{

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BanggoodShop\BanggoodShop.csproj" />
<ProjectReference Include="..\..\SimpleLogger\SimpleLogger.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using MultiShop.ShopFramework;
using SimpleLogger;
using Xunit;
using Xunit.Abstractions;
namespace BanggoodShop.Tests
{
public class ShopTest
{
public ShopTest(ITestOutputHelper output)
{
Logger.AddLogListener(new XUnitLogger(output));
}
[Fact]
public async void Search_CAD_ResultsFound()
{
//Given
const int MAX_RESULTS = 100;
Shop shop = new Shop();
shop.UseProxy = false;
//When
shop.Initialize();
shop.SetupSession("samsung galaxy 20 case", Currency.CAD);
//Then
int count = 0;
await foreach (ProductListing listing in shop)
{
count += 1;
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
if (count >= MAX_RESULTS) return;
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using SimpleLogger;
using Xunit.Abstractions;
namespace BanggoodShop
{
public class XUnitLogger : ILogReceiver
{
public LogLevel Level => LogLevel.Debug;
public string Identifier => GetType().Name;
private ITestOutputHelper outputHelper;
public XUnitLogger(ITestOutputHelper output)
{
this.outputHelper = output;
}
public void Flush()
{
}
public void LogMessage(string message, DateTime time, LogLevel level)
{
try
{
outputHelper.WriteLine($"[{time.ToShortTimeString()}][{level.ToString()}]: {message}");
}
catch (InvalidOperationException) { };
}
}
}