-
Notifications
You must be signed in to change notification settings - Fork 20
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
feature: add semantic version types #236
Conversation
…qual and GreaterOrEqual method
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.
first pass.
[Test] | ||
public void TestGEMatcherReturnsFalseWhenAttributeValueIsLessButTrueForEqualToConditionValue() | ||
{ | ||
Assert.That(GECondition.Evaluate(null, new UserAttributes { { "distance_ge", 5 } }, Logger), Is.False); |
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.
use Assert.IsTrue or Assert.IsFalse
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.
Evaluate return bool? and Assert.IsTrue expects bool. That is the reason I used Assert.That
private BaseCondition ExactStrCondition = new BaseCondition { Name = "browser_type", Value = "firefox", Match = "exact", Type = "custom_attribute" }; | ||
private BaseCondition ExactBoolCondition = new BaseCondition { Name = "is_registered_user", Value = false, Match = "exact", Type = "custom_attribute" }; | ||
private BaseCondition ExactDecimalCondition = new BaseCondition { Name = "pi_value", Value = 3.14, Match = "exact", Type = "custom_attribute" }; | ||
private BaseCondition ExactIntCondition = new BaseCondition { Name = "lasers_count", Value = 9000, Match = "exact", Type = "custom_attribute" }; | ||
private BaseCondition InfinityIntCondition = new BaseCondition { Name = "max_num_value", Value = 9223372036854775807, Match = "exact", Type = "custom_attribute" }; | ||
private BaseCondition SemVerLTCondition = new BaseCondition { Name = "semversion_lt", Value = "3.7.1", Match = "semver_lt", Type = "custom_attribute" }; |
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.
Can you please append values, so unit test will have more clarity.
@@ -156,6 +170,35 @@ public class BaseCondition : ICondition | |||
return Convert.ToDouble(attributeValue) > Convert.ToDouble(Value); | |||
} | |||
|
|||
public bool? GreaterOrEqualThanEvaluator(object attributeValue, ILogger logger) |
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.
Am not in favor of all these evaluator or we should put common logic in a separate method, the only evaluation logic should be kept inside every evaluator.
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.
Lets talk offline. CommonEvaluator should return either 0, 1, -1 or raise exception. We shouldn't parse anything in GE, LE, EQ (SemVer).
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.
Looks good. Can. we just add a few invalid semver tests mentioned below?
} | ||
// major.minor.patch | ||
var versionPrefix = partialVersionParts[0]; | ||
versionSuffix = partialVersionParts[1]; |
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.
will this blow up if we have a version mistake like "2.0-"?
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.
good catch Tom, adding unit tests but it will be caught before this line.
{
// throw error
throw new Exception("Invalid Semantic Version.");
}```
|
||
#endregion // LEMatcher Tests | ||
|
||
#region SemVerLTMatcher Tests |
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.
Can we add some invalid attribute tests? (i.e. "3.0-", 3.x", 3.2, "3.0.0+", "+")?
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.
lgtm
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.
LGTM
Summary