示例#1
0
        public async Task Can_Update_Multiple_Items()
        {
            try
            {
                ICollectionRef <WrapperModel> reference = new CollectionReference <WrapperModel>(litedbloc, "update_collection");
                reference.Insert(DataProvider.GetModel(10));
                await reference.Commit();

                PagedResult <WrapperModel> _pagedForUpdate = reference.GetPaged(new PageOptions(0, 10), new SortOptions(SortOptions.Order.DSC, "_id"));
                foreach (WrapperModel _model in _pagedForUpdate.Result)
                {
                    _model.Word   = DataProvider.Word();
                    _model.Number = DataProvider.Number();
                }
                reference.Update(_pagedForUpdate.Result);
                await reference.Commit();

                PagedResult <WrapperModel> _pagedForChecking = reference.GetPaged(new PageOptions(0, 10), new SortOptions(SortOptions.Order.DSC, "_id"));
                foreach (WrapperModel _model in _pagedForChecking.Result)
                {
                    VerifyAssertModels(_pagedForUpdate.Result[_pagedForChecking.Result.IndexOf(_model)], _model);
                }

                reference.Drop();
            }
            catch (Exception ex)
            { Assert.Null(ex); }
        }
示例#2
0
        public async Task Can_Remove_Item()
        {
            try
            {
                ICollectionRef <WrapperModel> reference = new CollectionReference <WrapperModel>(litedbloc, "delete_collection");
                using WrapperModel _model = DataProvider.GetModel();
                reference.Insert(_model);
                await reference.Commit();

                reference.Remove(_model._ID);
                await reference.Commit();

                using WrapperModel _deletedModel = reference.Get(_model._ID);
                Assert.Null(_deletedModel);
                reference.Drop();
            }
            catch (Exception ex)
            { Assert.Null(ex); }
        }
示例#3
0
        public async Task Can_Remove_Multiple_Items()
        {
            try
            {
                ICollectionRef <WrapperModel> reference = new CollectionReference <WrapperModel>(litedbloc, "delete_collection");
                reference.Insert(DataProvider.GetModel(10));
                await reference.Commit();

                PagedResult <WrapperModel> _pagedForDelete = reference.GetPaged(new PageOptions(0, 10), new SortOptions(SortOptions.Order.DSC, "_id"));
                reference.Remove(_pagedForDelete.Result.Select(_d => _d._ID).ToList());
                await reference.Commit();

                PagedResult <WrapperModel> _pagedForChecking = reference.GetPaged(new PageOptions(0, 10), new SortOptions(SortOptions.Order.DSC, "_id"));
                Assert.Equal(0, _pagedForChecking.TotalRows);
                Assert.False(_pagedForChecking.Result.Any());

                reference.Drop();
            }
            catch (Exception ex)
            { Assert.Null(ex); }
        }
示例#4
0
        public async Task Can_Insert_Multiple_Items()
        {
            try
            {
                ICollectionRef <WrapperModel> reference = new CollectionReference <WrapperModel>(litedbloc, "insert_collection");
                reference.Insert(DataProvider.GetModel(20));
                await reference.Commit();

                reference.Drop();
            }
            catch (Exception ex)
            { Assert.Null(ex); }
        }
示例#5
0
        public async Task Can_Update_Item()
        {
            try
            {
                ICollectionRef <WrapperModel> reference = new CollectionReference <WrapperModel>(litedbloc, "update_collection");
                using (WrapperModel _model = DataProvider.GetModel())
                {
                    reference.Insert(_model);
                    await reference.Commit();

                    using WrapperModel _inserted = reference.Get(_model._ID);
                    _inserted.Word   = DataProvider.Word();
                    _inserted.Number = DataProvider.Number();
                    reference.Update(_inserted);
                    await reference.Commit();

                    using WrapperModel _updated = reference.Get(_inserted._ID);
                    VerifyAssertModels(_inserted, _updated);
                }
                reference.Drop();
            }
            catch (Exception ex)
            { Assert.Null(ex); }
        }