Skip to content

Commit

Permalink
fix some unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikus1993 committed Jan 27, 2024
1 parent f1ec763 commit a11dedd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
16 changes: 16 additions & 0 deletions src/XboxPromotionCheckerBot.App/Core/Filters/GameNameFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

namespace XboxPromotionCheckerBot.App.Core.Filters;

public sealed record FuzzGame(Guid Id, string Title)

Check warning on line 7 in src/XboxPromotionCheckerBot.App/Core/Filters/GameNameFilter.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_normalizedTitle' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
private readonly string _normalizedTitle;
public FuzzGame(string Title): this(Guid.NewGuid(), Title)
{
ArgumentException.ThrowIfNullOrEmpty(Title);
_normalizedTitle = Title.Normalize().ToUpperInvariant();
}

public bool Contains(XboxGame game)
{
var title = game.Title.Normalize().ToUpperInvariant();
return title.Contains(_normalizedTitle, StringComparison.InvariantCultureIgnoreCase);
}
}

public sealed class GameNameFilter : IGamesFilter
{
private readonly FuzzGame[] _games;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,13 @@
using Lucene.Net.Search;
using Lucene.Net.Store;
using Lucene.Net.Util;
using XboxPromotionCheckerBot.App.Core.Filters;
using XboxPromotionCheckerBot.App.Core.Repositories;
using XboxPromotionCheckerBot.App.Core.Types;
using XboxPromotionCheckerBot.App.Infrastructure.Extensions;

namespace XboxPromotionCheckerBot.App.Infrastructure.Repositories;

public sealed record FuzzGame(Guid Id, string Title)
{
private readonly string _normalizedTitle;
public FuzzGame(string Title): this(Guid.NewGuid(), Title)
{
ArgumentException.ThrowIfNullOrEmpty(Title);
_normalizedTitle = Title.Normalize().ToUpperInvariant();
}

public bool Contains(XboxGame game)
{
var title = game.Title.Normalize().ToUpperInvariant();
return title.Contains(_normalizedTitle, StringComparison.InvariantCultureIgnoreCase);
}
}

public sealed class FuzzyGameSearcher : IGameSearcher
{
const LuceneVersion LuceneVersion = Lucene.Net.Util.LuceneVersion.LUCENE_48;
Expand Down

0 comments on commit a11dedd

Please sign in to comment.