private IEnumerator Examples()
    {
        //  Get Environments
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get environments");
        if (!_service.GetEnvironments(OnGetEnvironments, OnFail))
        {
            Log.Debug("ExampleDiscovery.GetEnvironments()", "Failed to get environments");
        }
        while (!_getEnvironmentsTested)
        {
            yield return(null);
        }

        //  Wait for environment to be ready
        Runnable.Run(CheckEnvironmentState(0f));
        while (!_isEnvironmentReady)
        {
            yield return(null);
        }

        //  GetEnvironment
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get environment");
        if (!_service.GetEnvironment(OnGetEnvironment, OnFail, _environmentId))
        {
            Log.Debug("ExampleDiscovery.GetEnvironment()", "Failed to get environment");
        }
        while (!_getEnvironmentTested)
        {
            yield return(null);
        }

        //  Get Configurations
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get configurations");
        if (!_service.GetConfigurations(OnGetConfigurations, OnFail, _environmentId))
        {
            Log.Debug("ExampleDiscovery.GetConfigurations()", "Failed to get configurations");
        }
        while (!_getConfigurationsTested)
        {
            yield return(null);
        }

        //  Add Configuration
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to add configuration");
        if (!_service.AddConfiguration(OnAddConfiguration, OnFail, _environmentId, _configurationJson.Replace("{guid}", System.Guid.NewGuid().ToString())))
        {
            Log.Debug("ExampleDiscovery.AddConfiguration()", "Failed to add configuration");
        }
        while (!_addConfigurationTested)
        {
            yield return(null);
        }

        //  Get Configuration
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get configuration");
        if (!_service.GetConfiguration(OnGetConfiguration, OnFail, _environmentId, _createdConfigurationId))
        {
            Log.Debug("ExampleDiscovery.GetConfiguration()", "Failed to get configuration");
        }
        while (!_getConfigurationTested)
        {
            yield return(null);
        }

        //  Preview Configuration
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to preview configuration");
        if (!_service.PreviewConfiguration(OnPreviewConfiguration, OnFail, _environmentId, _createdConfigurationId, null, _filePathToIngest, _metadata))
        {
            Log.Debug("ExampleDiscovery.PreviewConfiguration()", "Failed to preview configuration");
        }
        while (!_previewConfigurationTested)
        {
            yield return(null);
        }

        //  Get Collections
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get collections");
        if (!_service.GetCollections(OnGetCollections, OnFail, _environmentId))
        {
            Log.Debug("ExampleDiscovery.GetCollections()", "Failed to get collections");
        }
        while (!_getCollectionsTested)
        {
            yield return(null);
        }

        //  Add Collection
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to add collection");
        if (!_service.AddCollection(OnAddCollection, OnFail, _environmentId, _createdCollectionName + System.Guid.NewGuid().ToString(), _createdCollectionDescription, _createdConfigurationId))
        {
            Log.Debug("ExampleDiscovery.AddCollection()", "Failed to add collection");
        }
        while (!_addCollectionTested)
        {
            yield return(null);
        }

        //  Get Collection
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get collection");
        if (!_service.GetCollection(OnGetCollection, OnFail, _environmentId, _createdCollectionId))
        {
            Log.Debug("ExampleDiscovery.GetCollection()", "Failed to get collection");
        }
        while (!_getCollectionTested)
        {
            yield return(null);
        }

        if (!_service.GetFields(OnGetFields, OnFail, _environmentId, _createdCollectionId))
        {
            Log.Debug("ExampleDiscovery.GetFields()", "Failed to get fields");
        }
        while (!_getFieldsTested)
        {
            yield return(null);
        }

        //  Add Document
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to add document");
        if (!_service.AddDocument(OnAddDocument, OnFail, _environmentId, _createdCollectionId, _documentFilePath, _createdConfigurationId, null))
        {
            Log.Debug("ExampleDiscovery.AddDocument()", "Failed to add document");
        }
        while (!_addDocumentTested)
        {
            yield return(null);
        }

        //  Get Document
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get document");
        if (!_service.GetDocument(OnGetDocument, OnFail, _environmentId, _createdCollectionId, _createdDocumentID))
        {
            Log.Debug("ExampleDiscovery.GetDocument()", "Failed to get document");
        }
        while (!_getDocumentTested)
        {
            yield return(null);
        }

        //  Update Document
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to update document");
        if (!_service.UpdateDocument(OnUpdateDocument, OnFail, _environmentId, _createdCollectionId, _createdDocumentID, _documentFilePath, _createdConfigurationId, null))
        {
            Log.Debug("ExampleDiscovery.UpdateDocument()", "Failed to update document");
        }
        while (!_updateDocumentTested)
        {
            yield return(null);
        }

        //  Query
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to query");
        if (!_service.Query(OnQuery, OnFail, _environmentId, _createdCollectionId, naturalLanguageQuery: _query))
        {
            while (!_queryTested)
            {
                yield return(null);
            }
        }

        //  List Credentials
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to list credentials");
        _service.ListCredentials(OnListCredentials, OnFail, _environmentId);
        while (!_listCredentialsTested)
        {
            yield return(null);
        }

        //  Create Credentials
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create credentials");
        SourceCredentials credentialsParameter = new SourceCredentials()
        {
            SourceType        = SourceCredentials.SourceTypeEnum.box,
            CredentialDetails = new CredentialDetails()
            {
                CredentialType = CredentialDetails.CredentialTypeEnum.oauth2,
                EnterpriseId   = "myEnterpriseId",
                ClientId       = "myClientId",
                ClientSecret   = "myClientSecret",
                PublicKeyId    = "myPublicIdKey",
                Passphrase     = "myPassphrase",
                PrivateKey     = "myPrivateKey"
            }
        };

        _service.CreateCredentials(OnCreateCredentials, OnFail, _environmentId, credentialsParameter);
        while (!_createCredentialsTested)
        {
            yield return(null);
        }

        //  Get Credential
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get credential");
        _service.GetCredential(OnGetCredential, OnFail, _environmentId, _createdCredentialId);
        while (!_getCredentialTested)
        {
            yield return(null);
        }

        //  Get metrics event rate
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Get metrics event rate");
        _service.GetMetricsEventRate(OnGetMetricsEventRate, OnFail);
        while (!_getMetricsEventRateTested)
        {
            yield return(null);
        }

        //  Get metrics query
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Get metrics query");
        _service.GetMetricsQuery(OnGetMetricsQuery, OnFail);
        while (!_getMetricsQueryTested)
        {
            yield return(null);
        }

        //  Get metrics query event
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Get metrics query event");
        _service.GetMetricsQueryEvent(OnGetMetricsQueryEvent, OnFail);
        while (!_getMetricsQueryEventTested)
        {
            yield return(null);
        }

        //  Get metrics query no result
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Get metrics query no result");
        _service.GetMetricsQueryNoResults(OnGetMetricsQueryNoResult, OnFail);
        while (!_getMetricsQueryNoResultTested)
        {
            yield return(null);
        }

        //  Get metrics query token event
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Get metrics query token event");
        _service.GetMetricsQueryTokenEvent(OnGetMetricsQueryTokenEvent, OnFail);
        while (!_getMetricsQueryTokenEventTested)
        {
            yield return(null);
        }

        //  Query log
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to Query log");
        _service.QueryLog(OnQueryLog, OnFail);
        while (!_queryLogTested)
        {
            yield return(null);
        }

        //  Create event
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create event");
        CreateEventObject queryEvent = new CreateEventObject()
        {
            Type = CreateEventObject.TypeEnum.click,
            Data = new EventData()
            {
                EnvironmentId = _environmentId,
                SessionToken  = _sessionToken,
                CollectionId  = _createdCollectionId,
                DocumentId    = _createdDocumentID
            }
        };

        _service.CreateEvent(OnCreateEvent, OnFail, queryEvent);
        while (!_createEventTested)
        {
            yield return(null);
        }

        //  DeleteCredential
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete credential");
        _service.DeleteCredentials(OnDeleteCredentials, OnFail, _environmentId, _createdCredentialId);
        while (!_deleteCredentialsTested)
        {
            yield return(null);
        }

        //  Delete Document
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete document {0}", _createdDocumentID);
        if (!_service.DeleteDocument(OnDeleteDocument, OnFail, _environmentId, _createdCollectionId, _createdDocumentID))
        {
            Log.Debug("ExampleDiscovery.DeleteDocument()", "Failed to delete document");
        }
        while (!_deleteDocumentTested)
        {
            yield return(null);
        }

        _isEnvironmentReady = false;
        Runnable.Run(CheckEnvironmentState(_waitTime));
        while (!_isEnvironmentReady)
        {
            yield return(null);
        }

        //  Create stopword list
        using (FileStream fs = File.OpenRead(_stopwordsFilepath))
        {
            Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create stopword list {0}", _createdCollectionId);
            _service.CreateStopwordList(OnCreateStopwordList, OnFail, _environmentId, _createdCollectionId, fs);
            while (!_createStopwordListTested)
            {
                yield return(null);
            }
        }

        //  Delete stopword list
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete stopword list {0}", _createdCollectionId);
        _service.DeleteStopwordList(OnDeleteStopwordList, OnFail, _environmentId, _createdCollectionId);
        while (!_deleteStopwordListTested)
        {
            yield return(null);
        }

        //  List Gateways
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to list gateways.");
        _service.ListGateways(OnListGateways, OnFail, _environmentId);
        while (!_listGatewaysTested)
        {
            yield return(null);
        }

        //  Create Gateway
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create gateway.");
        _service.CreateGateway(OnCreateGateway, OnFail, _environmentId);
        while (!_createGatewayTested)
        {
            yield return(null);
        }

        //  Get Gateway
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get gateway.");
        _service.GetGateway(OnGetGateway, OnFail, _environmentId, _createdGatewayId);
        while (!_getGatewayTested)
        {
            yield return(null);
        }

        //  Delete Gateway
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete gateway.");
        _service.GetGateway(OnDelteGateway, OnFail, _environmentId, _createdGatewayId);
        while (!_deleteGatewayTested)
        {
            yield return(null);
        }

        //  Delete Collection
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete collection {0}", _createdCollectionId);
        if (!_service.DeleteCollection(OnDeleteCollection, OnFail, _environmentId, _createdCollectionId))
        {
            Log.Debug("ExampleDiscovery.DeleteCollection()", "Failed to delete collection");
        }
        while (!_deleteCollectionTested)
        {
            yield return(null);
        }

        _isEnvironmentReady = false;
        Runnable.Run(CheckEnvironmentState(_waitTime));
        while (!_isEnvironmentReady)
        {
            yield return(null);
        }

        //  Delete Configuration
        Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete configuration {0}", _environmentId);
        if (!_service.DeleteConfiguration(OnDeleteConfiguration, OnFail, _environmentId, _createdConfigurationId))
        {
            Log.Debug("ExampleDiscovery.DeleteConfiguration()", "Failed to delete configuration");
        }
        while (!_deleteConfigurationTested)
        {
            yield return(null);
        }

        _isEnvironmentReady = false;
        Runnable.Run(CheckEnvironmentState(_waitTime));
        while (!_isEnvironmentReady)
        {
            yield return(null);
        }

        Log.Debug("ExampleDiscovery.RunTest()", "Discovery examples complete.");
    }