public async Task TestCreateDatabaseWithDefaultLeaderAsync()
    {
        var databaseId    = $"my-db-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
        var defaultLeader = "us-central1";
        var createDatabaseWithDefaultLeaderAsyncSample = new CreateDatabaseWithDefaultLeaderAsyncSample();
        var database = await createDatabaseWithDefaultLeaderAsyncSample
                       .CreateDatabaseWithDefaultLeaderAsync(_spannerFixture.ProjectId, _spannerFixture.InstanceIdWithMultiRegion, databaseId, defaultLeader);

        Assert.Equal(defaultLeader, database.DefaultLeader);
    }
示例#2
0
    public async Task TestGetDatabaseDefaultLeaderFromInformationSchemaAsync()
    {
        var databaseId    = $"my-db-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
        var defaultLeader = "us-central1";
        var sample        = new CreateDatabaseWithDefaultLeaderAsyncSample();
        var getDatabaseDefaultLeaderFromInformationSchemaAsyncSample = new GetDatabaseDefaultLeaderFromInformationSchemaAsyncSample();

        // Create Database with default leader
        await sample.CreateDatabaseWithDefaultLeaderAsync(_spannerFixture.ProjectId, _spannerFixture.InstanceIdWithMultiRegion, databaseId, defaultLeader);

        // Get Database default leader
        var leader = await getDatabaseDefaultLeaderFromInformationSchemaAsyncSample
                     .GetDatabaseDefaultLeaderFromInformationSchemaAsync(_spannerFixture.ProjectId, _spannerFixture.InstanceIdWithMultiRegion, databaseId);

        Assert.Equal(defaultLeader, leader);
    }