Renamed everything from MultiShop to Props.
This commit is contained in:
@@ -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="..\..\..\..\Libraries\SimpleLogger\SimpleLogger.csproj" />
|
||||
<ProjectReference Include="..\..\..\Props.Shop\AliExpressModule\Props.Shop.AliExpressModule.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -0,0 +1,59 @@
|
||||
using Props.Shop.Framework;
|
||||
using SimpleLogger;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Props.Shop.AliExpressModule.Tests
|
||||
{
|
||||
public class ShopTest
|
||||
{
|
||||
public ShopTest(ITestOutputHelper output)
|
||||
{
|
||||
Logger.AddLogListener(new XUnitLogger(output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Search_SearchForItem_MultiplePages()
|
||||
{
|
||||
//Given
|
||||
const int MAX_RESULTS = 120;
|
||||
Shop shop = new Shop();
|
||||
shop.UseProxy = false;
|
||||
shop.Initialize();
|
||||
//When
|
||||
shop.SetupSession("mpu6050", Currency.CAD);
|
||||
//Then
|
||||
int count = 0;
|
||||
await foreach (ProductListing listing in shop)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
||||
count += 1;
|
||||
if (count > MAX_RESULTS) return;
|
||||
}
|
||||
shop.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Search_USD_ResultsFound()
|
||||
{
|
||||
//Given
|
||||
const int MAX_RESULTS = 120;
|
||||
Shop shop = new Shop();
|
||||
shop.UseProxy = false;
|
||||
shop.Initialize();
|
||||
//When
|
||||
shop.SetupSession("mpu6050", Currency.USD);
|
||||
//Then
|
||||
|
||||
int count = 0;
|
||||
await foreach (ProductListing listing in shop)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(listing.Name));
|
||||
Assert.True(listing.LowerPrice != 0);
|
||||
count += 1;
|
||||
if (count > MAX_RESULTS) return;
|
||||
}
|
||||
shop.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using SimpleLogger;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Props.Shop.AliExpressModule
|
||||
{
|
||||
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) { };
|
||||
}
|
||||
}
|
||||
}
|
@@ -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="..\..\..\Props.Shop\BanggoodModule\Props.Shop.BanggoodModule.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Libraries\SimpleLogger\SimpleLogger.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -0,0 +1,35 @@
|
||||
using Props.Shop.Framework;
|
||||
using SimpleLogger;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Props.Shop.BanggoodModule.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using SimpleLogger;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Props.Shop.BanggoodModule
|
||||
{
|
||||
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