public void Model_Success() { _service = new LanguageTranslatorService(_username, _password); _service.Endpoint = _endpoint; TranslationModel createModelResult; using (FileStream fs = File.OpenRead(_glossaryPath)) { createModelResult = _service.CreateModel(_baseModel, _customModelName, forcedGlossary: fs); if (createModelResult != null) { _customModelID = createModelResult.ModelId; } else { Console.WriteLine("result is null."); } } var result = _service.DeleteModel(_customModelID); Assert.IsNotNull(createModelResult); Assert.IsNotNull(result); Assert.IsTrue(result.Status == "OK"); }
public void DeleteModel_Success() { IClient client = this.CreateClient(); IRequest request = Substitute.For <IRequest>(); client.DeleteAsync(Arg.Any <string>()) .Returns(request); request.As <DeleteModelResult>() .Returns(Task.FromResult(new DetailedResponse <DeleteModelResult>() { Result = new DeleteModelResult() { Status = "success" } })); LanguageTranslatorService service = new LanguageTranslatorService(client); service.VersionDate = "versionDate"; var deletedModel = service.DeleteModel("model_id"); Assert.IsNotNull(deletedModel); client.Received().DeleteAsync(Arg.Any <string>()); Assert.IsTrue(deletedModel.Result.Status.Equals("success")); }
public void DeleteModel_Success() { languageTranslator = new LanguageTranslatorService(_userName, _password); languageTranslator.Endpoint = _endpoint; var result = languageTranslator.DeleteModel(_customModelID); Assert.IsNotNull(result); Assert.IsTrue(result.Status == "OK"); }
public void DeleteModel() { IamAuthenticator authenticator = new IamAuthenticator( apikey: "{apikey}"); LanguageTranslatorService service = new LanguageTranslatorService("2018-05-01", authenticator); var result = service.DeleteModel( modelId: "9f8d9c6f-2123-462f-9793-f17fdcb77cd6" ); Console.WriteLine(result.Response); }
public void DeleteModel_Catch_Exception() { IClient client = this.CreateClient(); IRequest request = Substitute.For <IRequest>(); client.DeleteAsync(Arg.Any <string>()) .Returns(x => { throw new AggregateException(new Exception()); }); LanguageTranslatorService service = new LanguageTranslatorService(client); var deletedModel = service.DeleteModel("model_id"); }
public void DeleteModel_ModelId_Null() { IClient client = this.CreateClient(); IRequest request = Substitute.For <IRequest>(); client.DeleteAsync(Arg.Any <string>()) .Returns(request); LanguageTranslatorService service = new LanguageTranslatorService(client); var deletedModel = service.DeleteModel(null); }
public void DeleteModel() { IamConfig config = new IamConfig( apikey: apikey ); LanguageTranslatorService service = new LanguageTranslatorService(versionDate, config); var result = service.DeleteModel( modelId: modelId ); Console.WriteLine(result.Response); }
private void DeleteModel() { Console.WriteLine(string.Format("Calling DeleteModel({0})...", _customModelID)); var result = _languageTranslator.DeleteModel(_customModelID); if (result != null) { Console.WriteLine("deleted: {0}", result.Deleted); } else { Console.WriteLine("Failed to delete models."); } }
private void DeleteModel() { Console.WriteLine(string.Format("Calling DeleteModel({0})...", _customModelID)); var result = _languageTranslator.DeleteModel(_customModelID); if (result != null) { Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); } else { Console.WriteLine("result is null."); } }
private DeleteModelResult DeleteModel(string modelId, Dictionary <string, object> customData = null) { Console.WriteLine("\nAttempting to DeleteModel()"); var result = service.DeleteModel(modelId: modelId, customData: customData); if (result != null) { Console.WriteLine("DeleteModel() succeeded:\n{0}", JsonConvert.SerializeObject(result, Formatting.Indented)); } else { Console.WriteLine("Failed to DeleteModel()"); } return(result); }
public void DeleteModel() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = url }; LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate); var result = service.DeleteModel( modelId: modelId ); Console.WriteLine(result.Response); }
public void DeleteModel_Success() { IClient client = Substitute.For <IClient>(); IRequest request = Substitute.For <IRequest>(); client.DeleteAsync(Arg.Any <string>()) .Returns(request); LanguageTranslatorService service = new LanguageTranslatorService(client); var versionDate = "versionDate"; service.VersionDate = versionDate; var modelId = "modelId"; var result = service.DeleteModel(modelId: modelId); request.Received().WithArgument("version", versionDate); client.Received().DeleteAsync($"{service.ServiceUrl}/v3/models/{modelId}"); }
public IEnumerator TestDeleteModel() { Log.Debug("LanguageTranslatorServiceV3IntegrationTests", "Attempting to DeleteModel..."); DeleteModelResult deleteModelResponse = null; service.DeleteModel( callback: (DetailedResponse <DeleteModelResult> response, IBMError error) => { Log.Debug("LanguageTranslatorServiceV3IntegrationTests", "DeleteModel result: {0}", response.Response); deleteModelResponse = response.Result; Assert.IsNotNull(deleteModelResponse); Assert.IsNotNull(deleteModelResponse.Status); Assert.IsTrue(deleteModelResponse.Status == "OK"); Assert.IsNull(error); }, modelId: customModelId ); while (deleteModelResponse == null) { yield return(null); } }
public void Model_Success() { DetailedResponse <TranslationModel> createModelResult; using (FileStream fs = File.OpenRead(glossaryPath)) { using (MemoryStream ms = new MemoryStream()) { fs.CopyTo(ms); service.WithHeader("X-Watson-Test", "1"); createModelResult = service.CreateModel( baseModelId: baseModel, forcedGlossary: ms, name: customModelName ); if (createModelResult != null) { customModelID = createModelResult.Result.ModelId; } else { Console.WriteLine("result is null."); } } } service.WithHeader("X-Watson-Test", "1"); var result = service.DeleteModel( modelId: customModelID ); Assert.IsNotNull(createModelResult); Assert.IsNotNull(result); Assert.IsTrue(result.Result.Status == "OK"); }
public void DeleteModel_Success() { IClient client = this.CreateClient(); IRequest request = Substitute.For <IRequest>(); client.DeleteAsync(Arg.Any <string>()) .Returns(request); request.As <DeleteModels>() .Returns(Task.FromResult(new DeleteModels() { Deleted = "success" })); LanguageTranslatorService service = new LanguageTranslatorService(client); var deletedModel = service.DeleteModel("model_id"); Assert.IsNotNull(deletedModel); client.Received().DeleteAsync(Arg.Any <string>()); Assert.IsTrue(deletedModel.Deleted.Equals("success")); }