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

Bugfix/#256 #259

Merged
merged 4 commits into from
Apr 15, 2024
Merged

Bugfix/#256 #259

merged 4 commits into from
Apr 15, 2024

Conversation

yollosun
Copy link
Contributor

@yollosun yollosun commented Feb 6, 2024

No description provided.

@yollosun yollosun changed the base branch from master to develop February 7, 2024 06:50
ValidateTypesMatching(comparableValue);

var maxValue = ConvertToIComparable(MaxValue);
var comparableValue = (IComparable)value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if value is not IComparable you will get cast exception. Need to check it for IComparable and add a test for that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I won’t be able to test this because the constructor does not accept values ​​except string, int, double

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have "public MaxAttribute(Type type, string maxValue"
So you can pass wrong type for test:

[Min(typeof(object), "12.5")]
public object Param { get; set; }

Check can be done in constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. what kind of exception i need to throw?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArgumentException.
"type is not IComparable, Actual type: {type.Name}"

ValidateTypesMatching(comparableValue);

var minValue = ConvertToIComparable(MinValue);
var comparableValue = (IComparable)value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if value is not IComparable you will get cast exception. Need to check it for IComparable and add a test for that case.

@i4004 i4004 merged commit 0669a2c into SimplifyNet:develop Apr 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants