Пример #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");
            }
        }