public void GetDocument_InvalidDocumentId_ThrowsDocumentNotFoundException() { var id = "000"; var collection = new MockMongoCollection <BsonDocument>(); _provider.GetDocumentById(id, collection); }
public void GetDocuments_GetAllDocuments_RetunsDocumentsInCollection() { var collection = new MockMongoCollection <Person>(); var documents = _provider.GetDocuments(collection); Assert.IsNotNull(documents); }
public void GetDocument_GivenDocumentId_ReturnsValidDocument() { var id = "123"; var collection = new MockMongoCollection <BsonDocument>(); var doc = _provider.GetDocumentById(id, collection); Assert.IsNotNull(doc); Assert.AreEqual(id, doc["_id"].AsString); }
public void AddToCollection_ValidDocument_InsertNewDocument() { var collection = new MockMongoCollection <Person>(); var person = new Person { Name = "john", Age = 20 }; _provider.AddToCollection <Person>(collection, person); Console.WriteLine(person.ToJson()); }
public void EditDocument_InvalidDocumentId_ThrowsDocumentNotFoundException() { // arrange var id = "000"; var document = new Person { Name = "updated name", Age = 50 }.ToBsonDocument(); var collection = new MockMongoCollection <BsonDocument>(); // act _provider.EditDocument(id, document, collection); }
public void EditDocument_UpdatingExsistingDocument() { // arrange var id = "123"; var document = new Person { Name = "updated name", Age = 50 }.ToBsonDocument(); var collection = new MockMongoCollection <BsonDocument>(); var oldDocument = _provider.GetDocumentById(id, collection); // act _provider.EditDocument(id, document, collection); Assert.AreEqual(oldDocument["_id"].AsString, document["_id"].AsString); Assert.AreNotEqual(oldDocument["name"].AsString, document["name"].AsString); }