public void FromDocument_DocumentHasNoError_ReturnsNull()
        {
            var document = new SimoKeyValues();

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.IsNull(errMsg);
        }
        public void FromDocument_DocumentHasErrorWithMessage_ReturnsNonNullWithMessage()
        {
            var document = new SimoKeyValues { { "ok", 0.0 }, {"errmsg", "Dummy"} };

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.AreEqual("Dummy", errMsg.Message);
        }
        public void FromDocument_DocumentHasErrorWithoutMessage_ReturnsNonNullWithDefaultMessage()
        {
            var document = new SimoKeyValues { { "ok", 0.0 } };

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.AreEqual(ExceptionMessages.MongoErrorMessage_Default, errMsg.Message);
        }
Ejemplo n.º 4
0
        public void FromDocument_DocumentHasNoError_ReturnsNull()
        {
            var document = new SimoKeyValues();

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.IsNull(errMsg);
        }
Ejemplo n.º 5
0
        public void FromDocument_DocumentHasErrorWithoutMessage_ReturnsNonNullWithDefaultMessage()
        {
            var document = new SimoKeyValues {
                { "ok", 0.0 }
            };

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.AreEqual(ExceptionMessages.MongoErrorMessage_Default, errMsg.Message);
        }
Ejemplo n.º 6
0
        public void FromDocument_DocumentHasErrorWithMessage_ReturnsNonNullWithMessage()
        {
            var document = new SimoKeyValues {
                { "ok", 0.0 }, { "errmsg", "Dummy" }
            };

            var errMsg = MongoDbErrorMessage.FromDocument(document);

            Assert.AreEqual("Dummy", errMsg.Message);
        }
Ejemplo n.º 7
0
        public static MongoDbErrorMessage FromDocument(SimoKeyValues document)
        {
            if (document.Keys.Count < 1)
                return null;

            var commandWasOk = document.GetDouble("ok") == 1.0;
            if (commandWasOk)
                return null;

            string errMsg = null;

            if (document.ContainsKey("errmsg"))
                errMsg = document.GetString("errmsg");

            return new MongoDbErrorMessage(errMsg);
        }
Ejemplo n.º 8
0
 internal static void AssertValue <T>(this SimoKeyValues kv, string key, T expected, Func <string, T> actual)
 {
     Assert.AreEqual(expected, actual(key));
 }