Exemplo n.º 1
0
        public void TestUpdate()
        {
            SomeGenericClass genericClass = new SomeGenericClass("war", "huh");

            MongoDbHandler.InsertRecordToDb(genericClass);

            var queryable = MongoDbHandler.GetQueryable <SomeGenericClass>().Where(x => x.key == "war").ToList();

            var element = queryable[0];

            element.key   = "newKey";
            element.value = "newValue";

            MongoDbHandler.UpdateRecordInDb(element, element.Id);

            queryable = MongoDbHandler.GetQueryable <SomeGenericClass>().Where(x => x.key == "newKey").ToList();

            if (queryable.Count > 0)
            {
                element = queryable[0];

                Assert.AreEqual(element.key, "newKey");
            }
            else
            {
                throw new AssertFailedException("Update failed, couldn't find updated element");
            }
        }
Exemplo n.º 2
0
        public void TestQueryable()
        {
            var someGenericClass = new SomeGenericClass("veryGenericKey", "veryGenericValue");

            someGenericClass.Id = ObjectId.Parse("5c9a0d8afe28b239e7da280d");

            MongoDbHandler.InsertRecordToDb(someGenericClass);

            var queryable = MongoDbHandler.GetQueryable <CaseReport>().Where(x => x.Id == ObjectId.Parse("5c9a0d8afe28b239e7da280d")).ToList();;

            Assert.AreEqual(queryable.Count, 1);
        }
Exemplo n.º 3
0
        public void TestInsert()
        {
            var key            = "war";
            SomeGenericClass y = new SomeGenericClass(key, "huh");

            MongoDbHandler.InsertRecordToDb(y);

            var queryable = MongoDbHandler.GetQueryable <SomeGenericClass>().Where(x => x.key == "war").ToList();;

            if (queryable.Count > 0)
            {
                var element = queryable[0];

                Assert.AreEqual(element.key, key);
            }
            else
            {
                throw new AssertFailedException("Insert failed, can't find inserted element");
            }
        }