Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/JA-120 Basic Search Logic #111

Merged
merged 13 commits into from
Jun 27, 2024
Merged
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
Loading