Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed May 2, 2024
1 parent fe4e40f commit a7a7c65
Showing 1 changed file with 68 additions and 0 deletions.
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

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'IsBehindMatcher' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 13 in tests/RepoM.App.Tests/RepositoryFiltering/QueryMatchers/IsBehindMatcherTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'IsBehindMatcher' could not be found (are you missing a using directive or an assembly reference?)

[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();
}
}

0 comments on commit a7a7c65

Please sign in to comment.