Not() public static method

Tests that the value of the named element does not match any of the tests that follow (see $not).
public static Not ( string name ) : QueryNot
name string The name of the element to test.
return QueryNot
        public void TestNotRegex()
        {
            var query    = Query.Not("name").Matches(new BsonRegularExpression("acme.*corp", "i"));
            var expected = "{ \"name\" : { \"$not\" : /acme.*corp/i } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotSize()
        {
            var query    = Query.Not("name").Size(1);
            var expected = "{ \"name\" : { \"$not\" : { \"$size\" : 1 } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotNinParams()
        {
            var query    = Query.Not("name").NotIn(1, 2, null, 3); // null will be skipped due to functional construction semantics
            var expected = "{ \"name\" : { \"$not\" : { \"$nin\" : [1, 2, 3] } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotExists()
        {
            var query    = Query.Not("name").Exists(false);
            var expected = "{ \"name\" : { \"$not\" : { \"$exists\" : false } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotElemMatch()
        {
            var query    = Query.Not("name").ElemMatch(Query.GT("x", 1));
            var expected = "{ \"name\" : { \"$not\" : { \"$elemMatch\" : { \"x\" : { \"$gt\" : 1 } } } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotInIEnumerableBsonValue()
        {
            var enumerable = new List <BsonValue> {
                1, 2, null, 3
            };                                                      // null will be skipped due to functional construction semantics
            var query    = Query.Not("name").In(enumerable);
            var expected = "{ \"name\" : { \"$not\" : { \"$in\" : [1, 2, 3] } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestNotAllBsonArray()
        {
            var array = new BsonArray {
                1, 2, null, 3
            };                                           // null will be skipped due to functional construction semantics
            var query    = Query.Not("name").All(array);
            var expected = "{ \"name\" : { \"$not\" : { \"$all\" : [1, 2, 3] } } }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }
        public void TestQueryNotNin()
        {
            var query1 = Query.Not("name").NotIn(_bsonValue);
            var query2 = Query.Not("name").NotIn(_bsonArray);
            var query3 = Query.Not("name").NotIn(_bsonValueArray);
            var query4 = Query.Not("name").NotIn(_bsonValueList);
            var query5 = Query.Not("name").NotIn(_ienumerableBsonValue);

            var expectedSingle   = "{ 'name' : { '$not' : { '$nin' : [1] } } }".Replace("'", "\"");
            var expectedMultiple = "{ 'name' : { '$not' : { '$nin' : [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());
        }