@@ -15,12 +15,13 @@ public class CosmosDataSourceExtensionTests : IDisposable
1515 readonly CosmosClient cosmosClient ;
1616 readonly Database testDatabase ;
1717 readonly string connectionString ;
18- readonly Action dismantleTestDb ;
18+ readonly Action dismantleTestDb = ( ) => { } ;
19+ readonly bool runTests = false ;
1920
2021 // Sets up a connection to CosmosDB.
2122 // Default values here are to a local Cosmos DB emulator.
2223 // Use the two environment variables to pass a custom connection.
23- public CosmosDataSourceExtensionTests ( ) {
24+ public CosmosDataSourceExtensionTests ( TestContext testContext ) {
2425 string endpoint = Environment . GetEnvironmentVariable ( "Cosmos_Endpoint" ) ?? "https://localhost:8081/" ;
2526 string accountKey = Environment . GetEnvironmentVariable ( "Cosmos_Key" ) ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" ;
2627 this . connectionString = $ "AccountEndpoint={ endpoint } ;AccountKey={ accountKey } ;";
@@ -37,9 +38,13 @@ public CosmosDataSourceExtensionTests() {
3738 ) ;
3839 this . cosmosClient = client ;
3940
40- //var account = client.ReadAccountAsync().Result;
41-
42- var db = client . CreateDatabaseAsync ( dbname , ( int ? ) null , new RequestOptions ( ) ) . Result ;
41+ DatabaseResponse db ;
42+ try {
43+ db = client . CreateDatabaseAsync ( dbname , ( int ? ) null , new RequestOptions ( ) ) . Result ;
44+ } catch ( Exception ) {
45+ testContext . WriteLine ( "Could not connect to Cosmos DB. Ignore these tests..." ) ;
46+ return ;
47+ }
4348 this . testDatabase = db . Database ;
4449 this . dismantleTestDb = ( ) => {
4550 try {
@@ -52,11 +57,20 @@ public CosmosDataSourceExtensionTests() {
5257
5358 public void Dispose ( )
5459 {
55- dismantleTestDb ( ) ;
60+ if ( runTests ) {
61+ dismantleTestDb ( ) ;
62+ }
63+ }
64+
65+ private void SkipTest ( ) {
66+ if ( ! runTests ) {
67+ throw new AssertInconclusiveException ( ) ;
68+ }
5669 }
5770
5871 [ TestMethod ]
5972 public async Task Test_Json_RoundTrip_WithLongValues ( ) {
73+ SkipTest ( ) ;
6074 var config = TestHelpers . CreateConfig ( new Dictionary < string , string > ( ) {
6175 { "UseRbacAuth" , "false" } ,
6276 { "ConnectionString" , this . connectionString } ,
@@ -94,6 +108,7 @@ await sinkExtension.WriteAsync(items.ToAsyncEnumerable(), config,
94108
95109 [ TestMethod ]
96110 public async Task Test_FromJson_WithLongValues ( ) {
111+ SkipTest ( ) ;
97112 var config = TestHelpers . CreateConfig ( new Dictionary < string , string > ( ) {
98113 { "UseRbacAuth" , "false" } ,
99114 { "ConnectionString" , this . connectionString } ,
0 commit comments