Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TestHelper.ShouldHaveValidationErrorFor.WithoutErrorCode broken in 11.0 #1937

@JothanChanes

Description

@JothanChanes

FluentValidation version

11.0

ASP.NET version

No response

Summary

When adding multiple validation rules the TestHelper's ShouldHaveValidationErrorFor.WithoutErrorCode throws for each and any specified error code (see MWE below). The issue was introduced by d4773d2, but I'm not yet(?) powerful enough to suggest a fix.

Steps to Reproduce

namespace FluentValidation.Tests {

	using Xunit;
	using FluentValidation.TestHelper;
	public class WithoutErrorCodeIssue_Reproduce {

		class A {
			public A() { s = ""; }
			public double d = 0;
			public string s;
		}

		class AV : AbstractValidator<A> {
			public AV() {
				RuleFor(a => a.d).InclusiveBetween(1, 3); // remove this line this line to make the test pass
				RuleFor(a => a.s).NotEmpty();
			}
		}

		[Fact]
		public void Reproduce() {
			var vld = new AV();
			var res = vld.TestValidate(new A());

			res.ShouldHaveValidationErrorFor(a => a.s).WithoutErrorCode("abc");
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions