Exemplo n.º 1
0
        public void TestLastErrorMessage()
        {
            using (_server.RequestStart(_database))
            {
                var c = new C {
                    List = new List <int>()
                };

                // insert it once
                _collection.Insert(c);
                var lastError = _server.GetLastError();
                Assert.AreEqual(0, lastError.DocumentsAffected);
                Assert.IsFalse(lastError.HasLastErrorMessage);
                Assert.IsNull(lastError.LastErrorMessage);
                Assert.IsFalse(lastError.UpdatedExisting);

                // insert it again (expect duplicate key error)
                _collection.Insert(c);
                lastError = _server.GetLastError();
                Assert.AreEqual(0, lastError.DocumentsAffected);
                Assert.IsTrue(lastError.HasLastErrorMessage);
                Assert.IsNotNull(lastError.LastErrorMessage);
                Assert.IsFalse(lastError.UpdatedExisting);
            }
        }
Exemplo n.º 2
0
 public void TestInsert()
 {
     using (database.RequestStart()) {
         collection.Insert(new BsonDocument());
         var result = server.GetLastError();
         Assert.IsFalse(result.HasLastErrorMessage);
         Assert.IsFalse(result.UpdatedExisting);
         Assert.AreEqual(0, result.DocumentsAffected); // note: DocumentsAffected is only set after an Update?
     }
 }
 public void TestInsert()
 {
     using (_database.RequestStart())
     {
         _collection.Insert(new BsonDocument());
         var result = _server.GetLastError();
         Assert.IsFalse(result.HasLastErrorMessage);
         Assert.IsFalse(result.UpdatedExisting);
         Assert.AreEqual(0, result.DocumentsAffected);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 서버의 가장 최근의 예외정보를 반환합니다.
 /// </summary>
 /// <param name="server"></param>
 /// <returns></returns>
 public static GetLastErrorResult GetLastError(this MongoServer server)
 {
     return(server.GetLastError());
 }
Exemplo n.º 5
0
 public GetLastErrorResult GetLastError()
 {
     return(_mongoServer.GetLastError());
 }