Completed AliExpress interfacing module.
Began work on assembly loading.
This commit is contained in:
27
test/AliExpressShop.Tests/AliExpressShop.Tests.csproj
Normal file
27
test/AliExpressShop.Tests/AliExpressShop.Tests.csproj
Normal 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\AliExpressShop\AliExpressShop.csproj" />
|
||||
<ProjectReference Include="..\..\SimpleLogger\SimpleLogger.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
73
test/AliExpressShop.Tests/ShopTest.cs
Normal file
73
test/AliExpressShop.Tests/ShopTest.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.Collections.Generic;
|
||||
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]
|
||||
public void Search_SearchForItem_ImportantInfoFound()
|
||||
{
|
||||
//Given
|
||||
Shop shop = new Shop();
|
||||
shop.Initiate(Currency.CAD);
|
||||
//When
|
||||
Task<IEnumerable<ProductListing>> listingsTask = shop.Search("mpu6050", 1);
|
||||
listingsTask.Wait();
|
||||
IEnumerable<ProductListing> listings = listingsTask.Result;
|
||||
Assert.NotEmpty(listings);
|
||||
foreach (ProductListing listing in listings)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
||||
Assert.True(listing.LowerPrice != 0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Search_SearchForItem_MultiplePages()
|
||||
{
|
||||
//Given
|
||||
Shop shop = new Shop();
|
||||
shop.Initiate(Currency.CAD);
|
||||
//When
|
||||
Task<IEnumerable<ProductListing>> listingsTask = shop.Search("mpu6050", 2);
|
||||
listingsTask.Wait();
|
||||
IEnumerable<ProductListing> listings = listingsTask.Result;
|
||||
//Then
|
||||
Assert.NotEmpty(listings);
|
||||
foreach (ProductListing listing in listings)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Search_USD_ResultsFound()
|
||||
{
|
||||
//Given
|
||||
Shop shop = new Shop();
|
||||
shop.Initiate(Currency.USD);
|
||||
//When
|
||||
Task<IEnumerable<ProductListing>> listingsTask = shop.Search("mpu6050", 1);
|
||||
listingsTask.Wait();
|
||||
IEnumerable<ProductListing> listings = listingsTask.Result;
|
||||
//Then
|
||||
Assert.NotEmpty(listings);
|
||||
foreach (ProductListing listing in listings)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
||||
Assert.True(listing.LowerPrice != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
test/AliExpressShop.Tests/XUnitLogger.cs
Normal file
33
test/AliExpressShop.Tests/XUnitLogger.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using SimpleLogger;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace GameServiceWarden.Core.Tests
|
||||
{
|
||||
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) { };
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user