- gRPC auth service for token validation - Value comparator system (string, numeric, boolean, datetime, collection) - Condition evaluator with strategy chain - Form definition and data improvements - Workflow instance/task endpoints updated - Seed data and EF design-time factory - Test coverage for comparators and handlers
102 lines
2.5 KiB
C#
102 lines
2.5 KiB
C#
namespace Workflow.Tests.Condition;
|
|
|
|
using FluentAssertions;
|
|
using Workflow.Domain.Expressions.Comparators;
|
|
using Xunit;
|
|
|
|
public class DateTimeComparatorTests
|
|
{
|
|
private readonly DateTimeComparator _sut = new();
|
|
|
|
[Fact]
|
|
public void Compare_Equals_SameDate_ReturnsTrue()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
_sut.Compare(date, "==", "2024-01-15").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_Equals_DifferentDate_ReturnsFalse()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
_sut.Compare(date, "==", "2024-01-16").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_NotEquals_ReturnsTrue()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
_sut.Compare(date, "!=", "2024-01-16").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_GreaterThan_ReturnsTrue()
|
|
{
|
|
var date = new DateTime(2024, 6, 1);
|
|
_sut.Compare(date, ">", "2024-01-01").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_LessThan_ReturnsTrue()
|
|
{
|
|
var date = new DateTime(2024, 1, 1);
|
|
_sut.Compare(date, "<", "2024-06-01").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_GreaterThanOrEqual_Equal()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
_sut.Compare(date, ">=", "2024-01-15").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_LessThanOrEqual_Equal()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
_sut.Compare(date, "<=", "2024-01-15").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_StringDate_ISO8601()
|
|
{
|
|
_sut.Compare("2024-01-15", "==", "2024-01-15").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_StringDate_WithTime()
|
|
{
|
|
_sut.Compare("2024-01-15T10:30:00", "==", "2024-01-15T10:30:00").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_InvalidDate_ReturnsFalse()
|
|
{
|
|
_sut.Compare("not-a-date", "==", "2024-01-15").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_NumericField_ReturnsFalse()
|
|
{
|
|
_sut.Compare(100, "==", "2024-01-15").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_NullField_ReturnsFalse()
|
|
{
|
|
_sut.Compare(null, "==", "2024-01-15").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_UnsupportedOperator_ReturnsFalse()
|
|
{
|
|
_sut.Compare(new DateTime(2024, 1, 15), "contains", "2024").Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Compare_GreaterThan_DateTimeLater()
|
|
{
|
|
_sut.Compare("2024-12-31", ">", "2024-01-01").Should().BeTrue();
|
|
}
|
|
}
|