-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from infoshareacademy/feature/ja-120-basic-se…
…arch-logic Feature/JA-120 Basic Search Logic
- Loading branch information
Showing
39 changed files
with
1,355 additions
and
209 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
Tests/TutorLizard.BusinessLogic.Tests/Models/Dtos/AdSearchCriteriaDtoTests.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,59 @@ | ||
using TutorLizard.Shared.Models.DTOs; | ||
|
||
namespace TutorLizard.BusinessLogic.Tests.Models.Dtos; | ||
public class AdSearchCriteriaDtoTests | ||
{ | ||
[Theory] | ||
[InlineData("", null, null, null, null, null)] | ||
[InlineData(null, 0, null, null, null, null)] | ||
[InlineData(null, null, 0, null, null, null)] | ||
[InlineData(null, null, null, "", null, null)] | ||
[InlineData(null, null, null, null, false, null)] | ||
[InlineData(null, null, null, null, null, 1)] | ||
[InlineData("", 0, 0, "", false, 1)] | ||
public void AnySearch_WhenAnySearchValueIsNotNull_ShouldReturnTrue(string? text, | ||
int? priceMin, | ||
int? priceMax, | ||
string? location, | ||
bool? isRemote, | ||
int? categoryId) | ||
{ | ||
// Arrange | ||
bool expected = true; | ||
|
||
// Act | ||
AdSearchCriteriaDto actual = new() | ||
{ | ||
Text = text, | ||
PriceMin = (decimal?)priceMin, | ||
PriceMax = (decimal?)priceMax, | ||
Location = location, | ||
IsRemote = isRemote, | ||
CategoryId = categoryId, | ||
}; | ||
|
||
// Assert | ||
Assert.Equal(expected, actual.AnySearch); | ||
} | ||
|
||
[Fact] | ||
public void AnySearch_WhenAllSearchValuesAreNull_ShouldReturnFalse() | ||
{ | ||
// Arrange | ||
bool expected = false; | ||
|
||
// Act | ||
AdSearchCriteriaDto actual = new() | ||
{ | ||
Text = null, | ||
PriceMin = null, | ||
PriceMax = null, | ||
Location = null, | ||
IsRemote = null, | ||
CategoryId = null, | ||
}; | ||
|
||
// Assert | ||
Assert.Equal(expected, actual.AnySearch); | ||
} | ||
} |
Oops, something went wrong.