Exemple #1
0
        public async Task DeleteManySuccessAsync()
        {
            var models = TestModelFactory.GetModels(5);
            await ZaabeeMongoClient.AddRangeAsync(models);

            var strings = models.Select(p => p.String);

            Assert.Equal(5L, await ZaabeeMongoClient.DeleteAsync <TestModel>(p => strings.Contains(p.String)));
        }
Exemple #2
0
        public void DeleteManySuccess()
        {
            var models = TestModelFactory.GetModels(5);

            ZaabeeMongoClient.AddRange(models);
            var strings = models.Select(p => p.String);

            Assert.Equal(5L, ZaabeeMongoClient.Delete <TestModel>(p => strings.Contains(p.String)));
        }
Exemple #3
0
        public async Task AddRangeAsync()
        {
            var models = TestModelFactory.GetModels(4).ToList();
            await ZaabeeMongoClient.AddRangeAsync(models);

            var ids     = models.Select(g => g.Id).ToList();
            var results = ZaabeeMongoClient.GetQueryable <TestModel>().Where(p => ids.Contains(p.Id))
                          .ToList();

            Assert.Equal(models.OrderBy(p => p.Id).ToList().ToJson(), results.OrderBy(p => p.Id).ToList().ToJson());
        }
Exemple #4
0
        public void UpdateManySuccess()
        {
            var models = TestModelFactory.GetModels(5);

            ZaabeeMongoClient.AddRange(models);
            var strings = models.Select(p => p.String);
            var ids     = models.Select(p => p.Id);
            var now     = DateTime.Now;
            var utcNow  = DateTime.UtcNow;
            var name    = Guid.NewGuid().ToString();
            var kids    = new List <TestModel>
            {
                new TestModel {
                    Id = Guid.NewGuid(), DateTime = DateTime.Now, DateTimeUtc = DateTime.UtcNow
                }
            };
            var modifyQuantity = ZaabeeMongoClient.Update(
                () => new TestModel
            {
                DateTime    = now,
                DateTimeUtc = utcNow,
                String      = name,
                KidList     = kids,
                EnumInt     = EnumInt.Banana
            },
                p => strings.Contains(p.String));

            models.ForEach(model =>
            {
                model.DateTime    = now;
                model.DateTimeUtc = utcNow;
                model.String      = name;
                model.KidList     = kids;
                model.EnumInt     = EnumInt.Banana;
            });

            var results = ZaabeeMongoClient.GetQueryable <TestModel>().Where(p => ids.Contains(p.Id)).ToList();

            Assert.Equal(5L, modifyQuantity);
            Assert.Equal(models.OrderBy(p => p.Id).ToList().ToJson(), results.OrderBy(p => p.Id).ToList().ToJson());
        }