-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
tests/RepoM.App.Tests/RepositoryFiltering/QueryMatchers/IsBehindMatcherTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
namespace RepoM.App.Tests.RepositoryFiltering.QueryMatchers; | ||
|
||
using FakeItEasy; | ||
using FluentAssertions; | ||
using RepoM.App.RepositoryFiltering.QueryMatchers; | ||
using RepoM.Core.Plugin.Repository; | ||
using RepoM.Core.Plugin.RepositoryFiltering.Clause.Terms; | ||
using Xunit; | ||
|
||
public class IsBehindMatcherTests | ||
{ | ||
private readonly IRepository _repository = A.Fake<IRepository>(); | ||
private readonly IsBehindMatcher _sut = new(); | ||
Check failure on line 13 in tests/RepoM.App.Tests/RepositoryFiltering/QueryMatchers/IsBehindMatcherTests.cs GitHub Actions / build (windows-latest)
Check failure on line 13 in tests/RepoM.App.Tests/RepositoryFiltering/QueryMatchers/IsBehindMatcherTests.cs GitHub Actions / build (windows-latest)
|
||
|
||
[Fact] | ||
public void IsMatch_ShouldReturnNull_WhenTermIsNotSimpleTerm() | ||
{ | ||
// arrange | ||
TermBase term = A.Fake<TermBase>(); | ||
|
||
// act | ||
var result = _sut.IsMatch(in _repository, in term); | ||
|
||
// assert | ||
result.Should().BeNull(); | ||
A.CallTo(_repository).MustNotHaveHappened(); | ||
} | ||
|
||
[Theory] | ||
[InlineData("","")] | ||
[InlineData("bla","")] | ||
[InlineData("is","")] | ||
[InlineData("", "bla")] | ||
[InlineData("x", "behind")] | ||
[InlineData("", "behind")] | ||
[InlineData("is", "abehind")] | ||
[InlineData("is", "Behind")] // invalid casing | ||
[InlineData("Is", "behind")] // invalid casing | ||
public void IsMatch_ShouldReturnNull_WhenTermAndValueAreNotIsBehind(string term, string value) | ||
{ | ||
// arrange | ||
TermBase simpleTerm = new SimpleTerm(term, value); | ||
|
||
// act | ||
var result = _sut.IsMatch(in _repository, in simpleTerm); | ||
|
||
// assert | ||
result.Should().BeNull(); | ||
A.CallTo(_repository).MustNotHaveHappened(); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsMatch_ShouldReturnRepositoryIsBehindValue_WhenTermAndValueMatches(bool repositoryIsBehind) | ||
{ | ||
// arrange | ||
A.CallTo(() => _repository.IsBehind).Returns(repositoryIsBehind); | ||
TermBase simpleTerm = new SimpleTerm("is", "behind"); | ||
|
||
// act | ||
var result = _sut.IsMatch(in _repository, in simpleTerm); | ||
|
||
// assert | ||
result.Should().Be(repositoryIsBehind); | ||
A.CallTo(() => _repository.IsBehind).MustHaveHappenedOnceExactly(); | ||
} | ||
} |