Skip to content

Commit

Permalink
fix: IN and NOT_IN Inverted now actually inverts the result (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus authored Jan 9, 2024
1 parent ee158d1 commit e1bed33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Unleash/Strategies/ConstraintUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ private static bool ValidateConstraint(Constraint constraint, UnleashContext con
var isIn = contextValue != null && constraint.Values.Contains(contextValue.Trim());

if (constraint.Operator == Operator.IN)
return isIn;
return constraint.Inverted ? !isIn : isIn;
if (constraint.Operator == Operator.NOT_IN)
return !isIn;
return constraint.Inverted ? isIn : !isIn;
}

return false;
}
}
}
}
10 changes: 5 additions & 5 deletions tests/Unleash.Tests/Integration/ClientSpecificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static TestFactory()

using (var client = new HttpClient())
{
var csTestsVersion = "v5.1.0";
var csTestsVersion = "v5.1.3";
var indexPath = $"https://raw.githubusercontent.com/Unleash/client-specification/{csTestsVersion}/specifications/";
var indexResponse = client.GetStringAsync(indexPath + "index.json").Result;
var indexFilePath = Path.Combine(specificationsPath, "index.json");
Expand Down Expand Up @@ -70,7 +70,7 @@ static TestFactory()
var tests = testDefinition.Tests?.Select(test =>
{
var testCaseData = new TestCaseData(CreateTestAction(testDefinition, test));
testCaseData.SetName($"{testDefinition.Name}.{test.Description.Replace(" ", "_").Replace(".", "_")}");
return testCaseData;
Expand Down Expand Up @@ -130,7 +130,7 @@ private static Action CreateVariantTestAction(TestDefinition testDefinition, Tes
Assert.AreEqual(testCase.ExpectedResult.IsEnabled, result.IsEnabled, testCase.Description);
Assert.AreEqual(testCase.ExpectedResult.FeatureEnabled, result.FeatureEnabled, testCase.Description);
Assert.AreEqual(testCase.ExpectedResult.Payload, result.Payload, testCase.Description);
};
};
}

public static IUnleash CreateUnleash(TestDefinition testDefinition, UnleashContextDefinition contextDefinition)
Expand Down Expand Up @@ -167,7 +167,7 @@ public static IUnleash CreateUnleash(TestDefinition testDefinition, UnleashConte

if (contextDefinition.CurrentTime.HasValue)
contextBuilder.CurrentTime(contextDefinition.CurrentTime.Value);

if (contextDefinition.Properties != null)
{
foreach (var property in contextDefinition.Properties)
Expand Down Expand Up @@ -200,4 +200,4 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
}
}
}
}
}

0 comments on commit e1bed33

Please sign in to comment.