public void MongoDbUtility_BuildFilter_Returns_Filter_For_Specified_Field() { var collection = _provider.GetDatabase().GetCollection <Well>(ObjectNames.Well141); var filter = MongoDbUtility.BuildFilter <Well>(ObjectTypes.Uid, ObjectTypes.Uid); Assert.IsNotNull(filter); var filterJson = filter.Render(collection.DocumentSerializer, collection.Settings.SerializerRegistry); Assert.IsNotNull(filterJson); Assert.AreEqual(1, filterJson.ElementCount); Assert.AreEqual(ObjectTypes.Uid, filterJson.Elements.ToList()[0].Name); filter = MongoDbUtility.BuildFilter <Well>(ObjectTypes.Uid, true); Assert.IsNotNull(filter); filterJson = filter.Render(collection.DocumentSerializer, collection.Settings.SerializerRegistry); Assert.IsNotNull(filterJson); Assert.AreEqual(1, filterJson.ElementCount); Assert.AreEqual(ObjectTypes.Uid, filterJson.Elements.ToList()[0].Name); AddParents(); filter = MongoDbUtility.BuildFilter <Well>(ObjectTypes.Uid, Well.Uid); Assert.IsNotNull(filter); var result = collection.Find(filter).ToList(); Assert.IsTrue(result.Count == 1); }
public void MongoDbUtility_BuildFilter_Can_Create_Filter_For_Specified_Field() { var collection = _provider.GetDatabase().GetCollection <Well>(ObjectNames.Well141); AddParents(); var filter = MongoDbUtility.BuildFilter <Well>(ObjectTypes.Uid, Well.Uid); Assert.IsNotNull(filter); var result = collection.Find(filter).ToList(); Assert.IsTrue(result.Count == 1); Assert.AreEqual(Well.Name, result[0].Name); }