Skip to content

Commit

Permalink
Merge pull request #111 from infoshareacademy/feature/ja-120-basic-se…
Browse files Browse the repository at this point in the history
…arch-logic

Feature/JA-120 Basic Search Logic
  • Loading branch information
Zjyslav committed Jun 27, 2024
2 parents ec1435d + 6f57639 commit b2e6bad
Show file tree
Hide file tree
Showing 39 changed files with 1,355 additions and 209 deletions.
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);
}
}
Loading

0 comments on commit b2e6bad

Please sign in to comment.