-
Notifications
You must be signed in to change notification settings - Fork 337
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Fixture cannot create Byte Array with RegularExpressionAttribute #1348
Comments
@RonSijm thank you for raising this, however I could not find any information about the [Theory]
[InlineData("[0-9]+", new [] {'0', '1'})]
[InlineData("[A-Z]+", new [] {'A', 'Z'})]
[InlineData("[a-z]+", new [] {'d', 'c'})]
public void AttributeValidatesByteArray(string pattern, char[] value)
{
var attribute = new RegularExpressionAttribute(pattern);
object bytes = value.Select(x => (byte)x).ToArray();
Validator.ValidateValue(bytes, new ValidationContext(this, null, null), new[] { attribute });
}
[Theory]
[InlineData("[0-9]+", new [] {'0', '1'})]
[InlineData("[A-Z]+", new [] {'A', 'Z'})]
[InlineData("[a-z]+", new [] {'d', 'c'})]
public void AttributeValidatesCharArray(string pattern, char[] value)
{
var attribute = new RegularExpressionAttribute(pattern);
Validator.ValidateValue(value, new ValidationContext(this, null, null), new[] { attribute });
}
[Theory]
[InlineData("[0-9]+", "01")]
[InlineData("[A-Z]+", "AZ")]
[InlineData("[a-z]+", "dc")]
public void AttributeValidatesString(string pattern, string value)
{
var attribute = new RegularExpressionAttribute(pattern);
Validator.ValidateValue(value, new ValidationContext(this, null, null), new[] { attribute });
} |
I'm not 100% sure what the attribute is supposed to do (As I mentioned, I'm implementing a client based on the hubspot swagger link that I provided, but besides that I'm not familiar with what the endpoint expects) If I had to guess, maybe the string form of the byte array is supposed to match the regex
I used NSwag toolchain v13.11.3.0 to generate the client library. I don't know if the attribute is actually going to be validated by anything. I guess NSwag just added it because the pattern is specified in the swagger file. In msdn: https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.regularexpressionattribute?view=net-6.0 their example seems to show:
Using it on an object, and not specifically a string (Which I'm also not sure of of how that's supposed to work... Anyways, if it's not valid, I suppose Fixture should just ignore it, instead of throw |
when a Byte Array has a RegularExpressionAttribute, the Fixture seems to treat it as string.
Scenario
Expected Behavior
An array of bytes is generated matching the regular expression
Actual Behavior
Tasks
More Information
I encountered this after generating a client library based on a swagger for Hubspot.
Swagger API: https://api.hubspot.com/api-catalog-public/v1/apis/crm/v3/extensions/accounting line 1407
The text was updated successfully, but these errors were encountered: