Ejemplo n.º 1
0
        public void Comparison_Success()
        {
            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);
                            service.WithHeader("X-Watson-Test", "1");
                            var comparisonResults = service.CompareDocuments(
                                file1: ms0,
                                file2: ms1,
                                file1ContentType: "application/pdf",
                                file2ContentType: "application/pdf",
                                file1Label: "Contract A",
                                file2Label: "Contract B",
                                model: compareComplyModel
                                );

                            Assert.IsNotNull(comparisonResults.Result);
                            Assert.IsTrue(comparisonResults.Result.Documents[0].Title == "Microsoft Word - contract_A.doc");
                            Assert.IsTrue(comparisonResults.Result.Documents[1].Title == "Microsoft Word - contract_B.doc");
                        }
                    }
                }
            }
        }
        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);
        }
Ejemplo n.º 3
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        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 Comparison_Success()
        {
            using (FileStream fs0 = File.OpenRead(contract_a))
            {
                using (FileStream fs1 = File.OpenRead(contract_b))
                {
                    var comparisonResults = service.CompareDocuments(fs0, fs1);

                    Assert.IsNotNull(comparisonResults);
                    Assert.IsTrue(comparisonResults.Documents[0].Title == "Microsoft Word - contract_A.doc");
                    Assert.IsTrue(comparisonResults.Documents[1].Title == "Microsoft Word - contract_B.doc");
                }
            }
        }
Ejemplo n.º 7
0
        public IEnumerator TestCompareDocuments()
        {
            Log.Debug("CompareComplyServiceV1IntegrationTests", "Attempting to CompareDocuments...");
            CompareReturn compareDocumentsResponse = null;

            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);
                            service.CompareDocuments(
                                callback: (DetailedResponse <CompareReturn> response, IBMError error) =>
                            {
                                Log.Debug("CompareComplyServiceV1IntegrationTests", "CompareDocuments result: {0}", response.Response);
                                compareDocumentsResponse = response.Result;
                                Assert.IsNotNull(compareDocumentsResponse);
                                Assert.IsNotNull(compareDocumentsResponse.Documents);
                                Assert.IsNull(error);
                            },
                                file1: ms0,
                                file2: ms1,
                                file1Label: "Contract A",
                                file2Label: "Contract B",
                                model: "contracts",
                                file1ContentType: Utility.GetMimeType(Path.GetExtension(contractAFilepath)),
                                file2ContentType: Utility.GetMimeType(Path.GetExtension(contractBFilepath))
                                );

                            while (compareDocumentsResponse == null)
                            {
                                yield return(null);
                            }
                        }
                    }
                }
            }
        }