Пример #1
0
        public void GetValueTest2()
        {
            var                  l        = _mockFactory.Create <TestLayout>();
            const BsonType       bsonType = BsonType.Boolean;
            var                  mf       = new MongoField("Name", l.Object, bsonType.ToString());
            const string         value    = "1122332";
            BsonValue            bv       = new BsonBoolean(true);
            var                  invoked  = false;
            BsonTryConvertMethod m        = (string s, out BsonValue converted) =>
            {
                converted = null;
                invoked   = true;
                return(false);
            };

            l.Protected().Setup("InitializeLayout").Verifiable();
            l.Protected().Setup <string>("GetFormattedMessage", _lei).Returns(value).Verifiable();
            _methodFactory.Setup(x => x.Create(bsonType)).Returns(m).Verifiable();
            _structConverter.Setup(x => x.BsonString(value)).Returns(bv).Verifiable();

            var res = Create().GetValue(mf, _lei);

            Assert.AreEqual(bv, res);
            Assert.IsTrue(invoked);
        }
Пример #2
0
        private static void Check <T, TV>([NotNull] BsonTryConvertMethod method, string value, bool r, [NotNull] Func <BsonValue, object> valueReader, TV exp)
            where T : BsonValue
        {
            BsonValue v;
            var       res = method(value, out v);

            Assert.AreEqual(r, res);
            Assert.IsTrue(v is T);
            Assert.AreEqual(exp, valueReader(v));
        }