-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bugfix/#256 #259
Conversation
ValidateTypesMatching(comparableValue); | ||
|
||
var maxValue = ConvertToIComparable(MaxValue); | ||
var comparableValue = (IComparable)value; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
No description provided.