From a5a5700a082c4fb3712193d36e372a014e5b4b2e Mon Sep 17 00:00:00 2001 From: Jeremy Skinner <90130+JeremySkinner@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:29:47 +0100 Subject: [PATCH] Fix test failing due to differences in DateTime.ToString behaviour on different runtimes --- src/FluentValidation.Tests/ValidatorTesterTester.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/FluentValidation.Tests/ValidatorTesterTester.cs b/src/FluentValidation.Tests/ValidatorTesterTester.cs index 10c8acef9..e077fab2f 100644 --- a/src/FluentValidation.Tests/ValidatorTesterTester.cs +++ b/src/FluentValidation.Tests/ValidatorTesterTester.cs @@ -955,15 +955,15 @@ public class ValidatorTesterTester { [Fact] public void ShouldHaveValidationErrorFor_WithPropertyName_Only_throws() { var validator = new InlineValidator(); - validator.RuleFor(x => DateTime.Now) + validator.RuleFor(x => x.Age) .Must((x, ct) => false) - .LessThan(new DateTime(1900, 1, 1)); + .LessThan(50); Assert.Throws(() => - validator.TestValidate(new Person()) - .ShouldHaveValidationErrorFor("Now") - .WithErrorMessage("The specified condition was not met for 'Now'.") + validator.TestValidate(new Person { Age = 100 }) + .ShouldHaveValidationErrorFor("Age") + .WithErrorMessage("The specified condition was not met for 'Age'.") .Only() - ).Message.ShouldEqual("Expected to have errors only matching specified conditions\n----\nUnexpected Errors:\n[0]: 'Now' must be less than '1/1/1900 12:00:00AM'.\n"); + ).Message.ShouldEqual("Expected to have errors only matching specified conditions\n----\nUnexpected Errors:\n[0]: 'Age' must be less than '50'.\n"); } [Fact]