Exemplo n.º 1
0
        public async Task SingleOrDefaultAsync_NoValue()
        {
            var tenantId   = TestConfiguration.GetTenantId();
            var connection = TestConfiguration.GetConnection();
            var context    = new MongoDbTenantContext(connection, tenantId);
            var dbSet      = new MongoDbTenantSet <QueryableAsyncModel>(context);

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

            var context2 = new MongoDbTenantContext(connection, tenantId + "-2");
            var dbSet2   = new MongoDbTenantSet <QueryableAsyncModel>(context2);

            Assert.IsNull(await dbSet2.SingleOrDefaultAsync());
        }
Exemplo n.º 2
0
        public async Task SingleOrDefaultAsync_HasValue()
        {
            var tenantId   = TestConfiguration.GetTenantId();
            var connection = TestConfiguration.GetConnection();
            var context    = new MongoDbTenantContext(connection, tenantId);
            var dbSet      = new MongoDbTenantSet <QueryableAsyncModel>(context);

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

            var context2 = new MongoDbTenantContext(connection, tenantId + "-2");
            var dbSet2   = new MongoDbTenantSet <QueryableAsyncModel>(context2);

            dbSet2.Add(new QueryableAsyncModel {
                Title = "SingleOrDefaultAsync_HasValue.1"
            });
            context2.SaveChanges();

            var result = await dbSet2.SingleOrDefaultAsync();

            Assert.AreEqual("SingleOrDefaultAsync_HasValue.1", result.Title);
        }