Skip to content
Permalink
Browse files
Adding operators
  • Loading branch information
anshuldavid13 committed Jun 13, 2022
1 parent bb9b341 commit 409b4f5a273550d7aaf03af95aab0803327aa405
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
@@ -54,6 +54,54 @@ public void Equal()
Assert.Equal(expected, actual);
}

[Fact]
public void NotEqual()
{
var actual = Filter.NotEqual("x", 1);
var expected = new Filter
{
PropertyFilter = new PropertyFilter
{
Op = Operator.NotEqual,
Property = new PropertyReference { Name = "x" },
Value = new Value { IntegerValue = 1 }
}
};
Assert.Equal(expected, actual);
}

[Fact]
public void NotIn()
{
var actual = Filter.NotIn("x", new ArrayValue(new string[2] { "1", "2" }));
var expected = new Filter
{
PropertyFilter = new PropertyFilter
{
Op = Operator.NotIn,
Property = new PropertyReference { Name = "x" },
Value = new ArrayValue(new string[2] { "1", "2" })
}
};
Assert.Equal(expected, actual);
}

[Fact]
public void In()
{
var actual = Filter.In("1", new ArrayValue(new string[2] { "1", "2" }));
var expected = new Filter
{
PropertyFilter = new PropertyFilter
{
Op = Operator.In,
Property = new PropertyReference { Name = "1" },
Value = new ArrayValue(new string[2] { "1", "2" })
}
};
Assert.Equal(expected, actual);
}

[Fact]
public void GreaterThan()
{
@@ -62,6 +62,34 @@ public static Filter And(IEnumerable<Filter> filters)
public static Filter Equal(string propertyName, Value propertyValue) =>
Property(propertyName, propertyValue, Operator.Equal);

/// <summary>
/// Creates a filter to check that the specified property is not equal to a given value.
/// </summary>
/// <param name="propertyName">The name of the property. Must not be null.</param>
/// <param name="propertyValue">The value to compare against. May be null, which indicates
/// a value with <see cref="Value.NullValue"/> set.</param>
/// <returns>The newly created filter.</returns>
public static Filter NotEqual(string propertyName, Value propertyValue) =>
Property(propertyName, propertyValue, Operator.NotEqual);

/// <summary>
/// Creates a filter to check that the specified property is in a given array of values.
/// </summary>
/// <param name="value">The name of the property. Must not be null.</param>
/// <param name="collection">The array of values to compare against. </param>
/// <returns>The newly created filter.</returns>
public static Filter In(string value, ArrayValue collection) =>
Property(value, collection, Operator.In);

/// <summary>
/// Creates a filter to check that the specified property is not in a given array of values.
/// </summary>
/// <param name="value">The name of the property. Must not be null.</param>
/// <param name="collection">The array of values to compare against. </param>
/// <returns>The newly created filter.</returns>
public static Filter NotIn(string value, ArrayValue collection) =>
Property(value, collection, Operator.NotIn);

/// <summary>
/// Creates a filter to check that the specified property is less than a given value.
/// </summary>

0 comments on commit 409b4f5

Please sign in to comment.