Fixed a AdafruitShop test.

This commit is contained in:
Harrison Deng 2022-04-24 01:25:46 -05:00
parent 89955968bf
commit 1d35e8a838
3 changed files with 7 additions and 5 deletions

4
Jenkinsfile vendored
View File

@ -11,7 +11,7 @@ pipeline {
}
stage("Test") {
steps {
dotnetTest project: "Props.Shop/Props.Shop.Tests.sln" unstableIfErrors: true, unstableIfWarnings: true
dotnetTest project: "Props.Shop/Props.Shop.Tests.sln", unstableIfErrors: true, unstableIfWarnings: true
}
}
stage("Publish") {
@ -36,7 +36,7 @@ pipeline {
}
stage("Test") {
steps {
dotnetTest project: "Props.Tests" unstableIfErrors: true, unstableIfWarnings: true
dotnetTest project: "Props.Tests", unstableIfErrors: true, unstableIfWarnings: true
}
}
stage("Publish") {

View File

@ -8,9 +8,11 @@ namespace Props.Shop.Adafruit.Tests
public class AdafruitShopTest
{
[Fact]
public async void TestSearch() {
public async void TestSearch()
{
AdafruitShop mockAdafruitShop = new AdafruitShop();
await mockAdafruitShop.Initialize(null, LoggerFactory.Create(builder => {
await mockAdafruitShop.Initialize(null, LoggerFactory.Create(builder =>
{
builder.AddXUnit();
}));
Assert.NotEmpty(mockAdafruitShop.Search("raspberry pi", new Filters()).ToEnumerable());

View File

@ -36,6 +36,7 @@ namespace Props.Shop.Adafruit
);
public async ValueTask Initialize(string workspaceDir, ILoggerFactory loggerFactory)
{
workspaceDir = workspaceDir ?? "";
this.workspaceDir = workspaceDir;
this.loggerFactory = loggerFactory;
logger = loggerFactory.CreateLogger<AdafruitShop>();
@ -105,7 +106,6 @@ namespace Props.Shop.Adafruit
LiveProductListingManager productListingManager = new LiveProductListingManager(http, loggerFactory.CreateLogger<LiveProductListingManager>(), listingData, configuration.MinDownloadInterval);
this.searchManager = new SearchManager(productListingManager, configuration.Similarity);
productListingManager.StartUpdateTimer(delay: 0, configuration.CacheLifespan);
}
public async Task<ProductListing> GetProductFromIdentifier(string identifier)