Example #1
0
        public void DeleteManySuccess()
        {
            var models = new GetModelService().GetModels(5);

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

            Assert.Equal(5L, _client.Delete <TestModel>(p => strings.Contains(p.String)));
        }
Example #2
0
        public void AddRange()
        {
            var models = new GetModelService().GetModels(3).ToList();

            _client.AddRange(models);
            var ids     = models.Select(g => g.Id).ToList();
            var results = _client.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());
        }
Example #3
0
        public void UpdateManySuccess()
        {
            var models = new GetModelService().GetModels(5);

            _client.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 = _client.Update(
                () => new TestModel
            {
                DateTime    = now,
                DateTimeUtc = utcNow,
                String      = name,
                Kids        = kids,
                EnumInt     = EnumInt.Banana
            },
                p => strings.Contains(p.String));

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

            var results = _client.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());
        }
Example #4
0
 public void Add(List <Order> orders)
 {
     _mongoClient.AddRange(Convert(orders));
     _cache.AddRange(orders.Select(order => new Tuple <string, Order>(order.Id, order)).ToList());
 }