public void TestInParams() { var query = Query.In("j", 2, 4, null, 6); // null will be skipped due to functional construction semantics var expected = "{ \"j\" : { \"$in\" : [2, 4, 6] } }"; Assert.AreEqual(expected, query.ToJson()); }
public void TestInIEnumerableBsonValue() { var enumerable = new List <BsonValue> { 2, 4, null, 6 }; // null will be skipped due to functional construction semantics var query = Query.In("j", enumerable); var expected = "{ \"j\" : { \"$in\" : [2, 4, 6] } }"; Assert.AreEqual(expected, query.ToJson()); }
public void TestInBsonArray() { var array = new BsonArray { 2, 4, null, 6 }; // null will be skipped due to functional construction semantics var query = Query.In("j", array); var expected = "{ \"j\" : { \"$in\" : [2, 4, 6] } }"; Assert.AreEqual(expected, query.ToJson()); }
public void TestQueryIn() { var query1 = Query.In("name", _bsonValue); var query2 = Query.In("name", _bsonArray); var query3 = Query.In("name", _bsonValueArray); var query4 = Query.In("name", _bsonValueList); var query5 = Query.In("name", _ienumerableBsonValue); var expectedSingle = "{ 'name' : { '$in' : [1] } }".Replace("'", "\""); var expectedMultiple = "{ 'name' : { '$in' : [1, 2, 3] } }".Replace("'", "\""); Assert.AreEqual(expectedSingle, query1.ToJson()); Assert.AreEqual(expectedMultiple, query2.ToJson()); Assert.AreEqual(expectedMultiple, query3.ToJson()); Assert.AreEqual(expectedMultiple, query4.ToJson()); Assert.AreEqual(expectedMultiple, query5.ToJson()); }
public void TestAndInNotIn() { var query = Query.And( Query.In("value", 1, 2, 3, 4), Query.NotIn("value", 11, 12, 13, 14) ); Assert.AreEqual( new BsonDocument { { "value", new BsonDocument { { "$in", new BsonArray { 1, 2, 3, 4 } }, { "$nin", new BsonArray { 11, 12, 13, 14 } } } } }, query.ToBsonDocument()); }