diff --git a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1.Tests/FilterTest.cs b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1.Tests/FilterTest.cs index c272b8f3f72b..bb672b05bc31 100644 --- a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1.Tests/FilterTest.cs +++ b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1.Tests/FilterTest.cs @@ -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() { diff --git a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs index 6bea35e05ad1..006b79b54c6b 100644 --- a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs +++ b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs @@ -62,6 +62,34 @@ public static Filter And(IEnumerable filters) public static Filter Equal(string propertyName, Value propertyValue) => Property(propertyName, propertyValue, Operator.Equal); + /// + /// Creates a filter to check that the specified property is not equal to a given value. + /// + /// The name of the property. Must not be null. + /// The value to compare against. May be null, which indicates + /// a value with set. + /// The newly created filter. + public static Filter NotEqual(string propertyName, Value propertyValue) => + Property(propertyName, propertyValue, Operator.NotEqual); + + /// + /// Creates a filter to check that the specified property is in a given array of values. + /// + /// The name of the property. Must not be null. + /// The array of values to compare against. + /// The newly created filter. + public static Filter In(string value, ArrayValue collection) => + Property(value, collection, Operator.In); + + /// + /// Creates a filter to check that the specified property is not in a given array of values. + /// + /// The name of the property. Must not be null. + /// The array of values to compare against. + /// The newly created filter. + public static Filter NotIn(string value, ArrayValue collection) => + Property(value, collection, Operator.NotIn); + /// /// Creates a filter to check that the specified property is less than a given value. ///