public void SuccessfullyBlocksUpdateRange()
        {
            var connection = TestConfiguration.GetConnection();
            var tenantId   = TestConfiguration.GetTenantId();
            var context    = new MongoDbTenantContext(connection, tenantId);
            var dbSet      = new MongoDbTenantSet <TestModel>(context);

            var entities = new[] {
                new TestModel
                {
                    Description = "SuccessfullyBlocksUpdateRange.1"
                },
                new TestModel
                {
                    Description = "SuccessfullyBlocksUpdateRange.2"
                }
            };

            dbSet.AddRange(entities);
            context.SaveChanges();

            dbSet = new MongoDbTenantSet <TestModel>(context);

            entities[0].Description = "SuccessfullyBlocksUpdateRange.1-Updated";
            entities[0].TenantId    = "qweasd";

            entities[1].Description = "SuccessfullyBlocksUpdateRange.2-Updated";
            entities[1].TenantId    = "qweasd";
            Assert.ThrowsException <MultiTenantException>(() => dbSet.UpdateRange(entities));
        }
        public void SuccessfullyUpdateRange()
        {
            var connection = TestConfiguration.GetConnection();
            var tenantId   = TestConfiguration.GetTenantId();
            var context    = new MongoDbTenantContext(connection, tenantId);
            var dbSet      = new MongoDbTenantSet <TestModel>(context);

            var entities = new[] {
                new TestModel
                {
                    Description = "SuccessfullyUpdateRange.1"
                },
                new TestModel
                {
                    Description = "SuccessfullyUpdateRange.2"
                }
            };

            dbSet.AddRange(entities);
            context.SaveChanges();

            dbSet = new MongoDbTenantSet <TestModel>(context);

            entities[0].Description = "SuccessfullyUpdateRange.1-Updated";
            entities[1].Description = "SuccessfullyUpdateRange.2-Updated";
            dbSet.UpdateRange(entities);

            Assert.IsFalse(dbSet.Any(m => m.Description == "SuccessfullyUpdateRange.1-Updated" || m.Description == "SuccessfullyUpdateRange.2-Updated"));
            context.SaveChanges();
            Assert.IsTrue(dbSet.Any(m => m.Description == "SuccessfullyUpdateRange.1-Updated"));
            Assert.IsTrue(dbSet.Any(m => m.Description == "SuccessfullyUpdateRange.2-Updated"));
        }
        public void SuccessfullyBlocksNulls()
        {
            var connection = TestConfiguration.GetConnection();
            var tenantId   = TestConfiguration.GetTenantId();
            var context    = new MongoDbTenantContext(connection, tenantId);
            var dbSet      = new MongoDbTenantSet <TestModel>(context);

            Assert.ThrowsException <ArgumentNullException>(() => dbSet.Add(null));
            Assert.ThrowsException <ArgumentNullException>(() => dbSet.AddRange(null));
            Assert.ThrowsException <ArgumentNullException>(() => dbSet.Update(null));
            Assert.ThrowsException <ArgumentNullException>(() => dbSet.UpdateRange(null));
        }