public void CompareComplyV1WithLoadedCredentials_Success() { CompareComplyService service = new CompareComplyService(); Assert.IsTrue(!string.IsNullOrEmpty(service.ApiKey)); Assert.IsTrue(!string.IsNullOrEmpty(service.Url)); }
public void Setup() { service = new CompareComplyService(versionDate); objectStorageCredentialsInputFilepath = "C:\\projects\\sdk-credentials\\cloud-object-storage-credentials-input.json"; objectStorageCredentialsOutputFilepath = "C:\\projects\\sdk-credentials\\cloud-object-storage-credentials-output.json"; }
public void ConvertToHtml_No_File() { IamAuthenticator authenticator = new IamAuthenticator(apikey: "apiKey"); CompareComplyService service = new CompareComplyService("versionDate", authenticator); service.ConvertToHtml(null, "filename"); }
public void CompareDocuments_Success() { IClient client = Substitute.For <IClient>(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(request); CompareComplyService service = new CompareComplyService(client); var versionDate = "versionDate"; service.VersionDate = versionDate; var file1 = new MemoryStream(); var file2 = new MemoryStream(); var file1ContentType = "file1ContentType"; var file2ContentType = "file2ContentType"; var file1Label = "file1Label"; var file2Label = "file2Label"; var model = "model"; var result = service.CompareDocuments(file1: file1, file2: file2, file1ContentType: file1ContentType, file2ContentType: file2ContentType, file1Label: file1Label, file2Label: file2Label, model: model); request.Received().WithArgument("version", versionDate); }
public void Constructor() { CompareComplyService service = new CompareComplyService(new IBMHttpClient()); Assert.IsNotNull(service); }
public void CompareDocuments() { IamAuthenticator authenticator = new IamAuthenticator( apikey: "{apikey}"); CompareComplyService service = new CompareComplyService("2018-10-15", authenticator); service.SetServiceUrl("{serviceUrl}"); using (FileStream fs0 = File.OpenRead("{path-to-file-1}")) { using (FileStream fs1 = File.OpenRead("{path-to-file-2}")) { using (MemoryStream ms0 = new MemoryStream()) { using (MemoryStream ms1 = new MemoryStream()) { fs0.CopyTo(ms0); fs1.CopyTo(ms1); var result = service.CompareDocuments( file1: ms0, file2: ms1, file1ContentType: "{file-1-content-type}", file2ContentType: "{file-2-content-type}", file1Label: "{file-1-label}", file2Label: "{file-2-label}" ); Console.WriteLine(result.Response); } } } } }
public void ListFeedback_Success() { IClient client = Substitute.For <IClient>(); IRequest request = Substitute.For <IRequest>(); client.GetAsync(Arg.Any <string>()) .Returns(request); CompareComplyService service = new CompareComplyService(client); var versionDate = "versionDate"; service.VersionDate = versionDate; var feedbackType = "feedbackType"; DateTime?before = DateTime.MaxValue; DateTime?after = DateTime.MaxValue; var documentTitle = "documentTitle"; var modelId = "modelId"; var modelVersion = "modelVersion"; var categoryRemoved = "categoryRemoved"; var categoryAdded = "categoryAdded"; var categoryNotChanged = "categoryNotChanged"; var typeRemoved = "typeRemoved"; var typeAdded = "typeAdded"; var typeNotChanged = "typeNotChanged"; long? pageLimit = 1; var cursor = "cursor"; var sort = "sort"; var includeTotal = false; var result = service.ListFeedback(feedbackType: feedbackType, before: before, after: after, documentTitle: documentTitle, modelId: modelId, modelVersion: modelVersion, categoryRemoved: categoryRemoved, categoryAdded: categoryAdded, categoryNotChanged: categoryNotChanged, typeRemoved: typeRemoved, typeAdded: typeAdded, typeNotChanged: typeNotChanged, pageLimit: pageLimit, cursor: cursor, sort: sort, includeTotal: includeTotal); request.Received().WithArgument("version", versionDate); }
public void Constructor() { CompareComplyService service = new CompareComplyService(); Assert.IsNotNull(service); }
public void CompareDocuments() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = url }; CompareComplyService service = new CompareComplyService(tokenOptions, versionDate); using (FileStream fs0 = File.OpenRead(contractAFilePath)) { using (FileStream fs1 = File.OpenRead(contractBFilePath)) { using (MemoryStream ms0 = new MemoryStream()) { using (MemoryStream ms1 = new MemoryStream()) { fs0.CopyTo(ms0); fs1.CopyTo(ms1); var result = service.CompareDocuments( file1: ms0, file2: ms1, file1ContentType: "application/pdf", file2ContentType: "application/pdf", file1Label: "Contract A", file2Label: "Contract B" ); Console.WriteLine(result.Response); } } } } }
public void CreateBatch_Success() { IClient client = Substitute.For <IClient>(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(request); CompareComplyService service = new CompareComplyService(client); var versionDate = "versionDate"; service.VersionDate = versionDate; var function = "function"; var inputCredentialsFile = new MemoryStream(); var inputBucketLocation = "inputBucketLocation"; var inputBucketName = "inputBucketName"; var outputCredentialsFile = new MemoryStream(); var outputBucketLocation = "outputBucketLocation"; var outputBucketName = "outputBucketName"; var model = "model"; var result = service.CreateBatch(function: function, inputCredentialsFile: inputCredentialsFile, inputBucketLocation: inputBucketLocation, inputBucketName: inputBucketName, outputCredentialsFile: outputCredentialsFile, outputBucketLocation: outputBucketLocation, outputBucketName: outputBucketName, model: model); request.Received().WithArgument("version", versionDate); }
public void ConvertToHtml() { IamConfig config = new IamConfig( apikey: apikey ); CompareComplyService service = new CompareComplyService(versionDate, config); service.SetEndpoint(url); using (FileStream fs = File.OpenRead(contractAFilePath)) { using (MemoryStream ms = new MemoryStream()) { fs.CopyTo(ms); var result = service.ConvertToHtml( file: ms, filename: Path.GetFileName(contractAFilePath), fileContentType: "application/pdf" ); Console.WriteLine(result.Response); } } }
//[TestMethod, ExpectedException(typeof(AggregateException))] public void ConvertToHtml_Catch_Exception() { IClient client = CreateClient(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(x => { throw new AggregateException(new ServiceResponseException(Substitute.For <IResponse>(), Substitute.For <HttpResponseMessage>(HttpStatusCode.BadRequest), string.Empty)); }); CompareComplyService service = new CompareComplyService(client); TokenOptions tokenOptions = new TokenOptions() { IamAccessToken = "iamAccessToken", ServiceUrl = "https://www.serviceurl.com" }; service.SetCredential(tokenOptions); service.VersionDate = "2018-02-16"; using (FileStream fs = File.OpenRead(tableFilePath)) { service.ConvertToHtml(fs); } }
public void ConvertToHtml() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = url }; CompareComplyService service = new CompareComplyService(tokenOptions, versionDate); using (FileStream fs = File.OpenRead(contractAFilePath)) { using (MemoryStream ms = new MemoryStream()) { fs.CopyTo(ms); var result = service.ConvertToHtml( file: ms, filename: Path.GetFileName(contractAFilePath), fileContentType: "application/pdf" ); Console.WriteLine(result.Response); } } }
public void CompareDocuments() { IamConfig config = new IamConfig( apikey: apikey ); CompareComplyService service = new CompareComplyService(versionDate, config); service.SetEndpoint(url); using (FileStream fs0 = File.OpenRead(contractAFilePath)) { using (FileStream fs1 = File.OpenRead(contractBFilePath)) { using (MemoryStream ms0 = new MemoryStream()) { using (MemoryStream ms1 = new MemoryStream()) { fs0.CopyTo(ms0); fs1.CopyTo(ms1); var result = service.CompareDocuments( file1: ms0, file2: ms1, file1ContentType: "application/pdf", file2ContentType: "application/pdf", file1Label: "Contract A", file2Label: "Contract B" ); Console.WriteLine(result.Response); } } } } }
public void Constructor_Version_Null() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = "iamApikey" }; CompareComplyService service = new CompareComplyService(tokenOptions, null); }
public void ConvertToHtml_No_FileName() { IamAuthenticator authenticator = new IamAuthenticator(apikey: "apiKey"); CompareComplyService service = new CompareComplyService("versionDate", authenticator); using (MemoryStream ms = Arg.Any <MemoryStream>()) { service.ConvertToHtml(ms, null); } }
public void ConvertToHtml_No_File() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = "iamApikey" }; CompareComplyService service = new CompareComplyService(tokenOptions, "versionDate"); service.ConvertToHtml(null); }
public void ConstructorExternalConfig() { var apikey = System.Environment.GetEnvironmentVariable("COMPARE_COMPLY_APIKEY"); System.Environment.SetEnvironmentVariable("COMPARE_COMPLY_APIKEY", "apikey"); CompareComplyService service = Substitute.For <CompareComplyService>("versionDate"); Assert.IsNotNull(service); System.Environment.SetEnvironmentVariable("COMPARE_COMPLY_APIKEY", apikey); }
public void Setup() { service = new CompareComplyService(versionDate); var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.Parent.Parent.FullName; string credentialsFilepath = parentDirectory + "projects" + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json"; objectStorageCredentialsInputFilepath = parentDirectory + "projects" + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "cloud-object-storage-credentials-input.json"; objectStorageCredentialsOutputFilepath = parentDirectory + "projects" + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "cloud-object-storage-credentials-output.json"; }
public void Constructor_With_TokenOptions() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = "iamApikey" }; CompareComplyService service = new CompareComplyService(tokenOptions, "2018-02-16"); Assert.IsNotNull(service); }
public IEnumerator UnityTestSetup() { if (service == null) { service = new CompareComplyService(versionDate); } while (!service.Authenticator.CanAuthenticate()) { yield return(null); } }
public IEnumerator UnityTestSetup() { if (service == null) { service = new CompareComplyService(versionDate); } while (!service.Credentials.HasIamTokenData()) { yield return(null); } }
public void ListBatches() { IamAuthenticator authenticator = new IamAuthenticator( apikey: "{apikey}"); CompareComplyService service = new CompareComplyService("2018-10-15", authenticator); service.SetServiceUrl("{serviceUrl}"); var result = service.ListBatches(); Console.WriteLine(result.Response); }
public void ConstructorNoUrl() { var apikey = System.Environment.GetEnvironmentVariable("COMPARE_COMPLY_APIKEY"); System.Environment.SetEnvironmentVariable("COMPARE_COMPLY_APIKEY", "apikey"); var url = System.Environment.GetEnvironmentVariable("COMPARE_COMPLY_URL"); System.Environment.SetEnvironmentVariable("COMPARE_COMPLY_URL", null); CompareComplyService service = Substitute.For <CompareComplyService>("versionDate"); Assert.IsTrue(service.ServiceUrl == "https://api.us-south.compare-comply.watson.cloud.ibm.com"); System.Environment.SetEnvironmentVariable("COMPARE_COMPLY_URL", url); }
public void ConvertToHtml_No_FileName() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = "iamApikey" }; CompareComplyService service = new CompareComplyService(tokenOptions, "versionDate"); using (MemoryStream ms = Arg.Any <MemoryStream>()) { service.ConvertToHtml(ms, null); } }
public void ListBatches() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = url }; CompareComplyService service = new CompareComplyService(tokenOptions, versionDate); var result = service.ListBatches(); Console.WriteLine(result.Response); }
public void ListBatches() { IamConfig config = new IamConfig( apikey: apikey ); CompareComplyService service = new CompareComplyService(versionDate, config); service.SetEndpoint(url); var result = service.ListBatches(); Console.WriteLine(result.Response); }
//[TestMethod] public void ConvertToHtml_Success() { IClient client = CreateClient(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(request); #region Response var response = Substitute.For <DetailedResponse <HTMLReturn> >(); response.Result = Substitute.For <HTMLReturn>(); response.Result.Author = "author"; response.Result.Html = "html"; response.Result.NumPages = "1"; response.Result.PublicationDate = "date"; response.Result.Title = "title"; #endregion request.WithArgument(Arg.Any <string>(), Arg.Any <string>()) .Returns(request); request.WithBody <FileStream>(Arg.Any <FileStream>()) .Returns(request); request.As <HTMLReturn>() .Returns(Task.FromResult(response)); CompareComplyService service = new CompareComplyService(client); TokenOptions tokenOptions = new TokenOptions() { IamAccessToken = "iamAccessToken", ServiceUrl = "https://www.serviceurl.com" }; service.SetCredential(tokenOptions); service.VersionDate = "versionDate"; DetailedResponse <HTMLReturn> result = null; using (MemoryStream fs = new MemoryStream()) { result = service.ConvertToHtml(fs, "filename"); } Assert.IsNotNull(result); client.Received().PostAsync(Arg.Any <string>()); Assert.IsTrue(result.Result.Author == "author"); Assert.IsTrue(result.Result.Html == "html"); Assert.IsTrue(result.Result.NumPages == "1"); Assert.IsTrue(result.Result.PublicationDate == "date"); Assert.IsTrue(result.Result.Title == "title"); }
public void ConvertToHtml_No_VersionDate() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = "iamApikey" }; CompareComplyService service = new CompareComplyService(tokenOptions, "versionDate"); service.VersionDate = null; using (FileStream fs = Arg.Any <FileStream>()) { service.ConvertToHtml(fs); } }
public void DeleteFeedback() { IamAuthenticator authenticator = new IamAuthenticator( apikey: "{apikey}"); CompareComplyService service = new CompareComplyService("2018-10-15", authenticator); service.SetServiceUrl("{serviceUrl}"); var result = service.DeleteFeedback( feedbackId: "{feedback-id}" ); Console.WriteLine(result.Response); }