public static void TearDown() { var environmentVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES"); var fileContent = File.ReadAllText(environmentVariable); var vcapServices = JObject.Parse(fileContent); string _endpoint = vcapServices["discovery"][0]["credentials"]["url"].Value <string>(); string _username = vcapServices["discovery"][0]["credentials"]["username"].Value <string>(); string _password = vcapServices["discovery"][0]["credentials"]["password"].Value <string>(); DiscoveryService _discovery = new DiscoveryService(_username, _password, DiscoveryService.DISCOVERY_VERSION_DATE_2017_11_07); if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdCollectionId) && !string.IsNullOrEmpty(_createdDocumentId)) { _discovery.DeleteDocument(_createdEnvironmentId, _createdCollectionId, _createdDocumentId); } if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdCollectionId)) { _discovery.DeleteCollection(_createdEnvironmentId, _createdCollectionId); } if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdConfigurationId)) { _discovery.DeleteConfiguration(_createdEnvironmentId, _createdConfigurationId); } if (!string.IsNullOrEmpty(_createdEnvironmentId)) { _discovery.DeleteEnvironment(_createdEnvironmentId); } }