Exemple #1
0
        public void SuccessPredictGoodStatus()
        {
            Console.WriteLine("SuccessPredictGoodStatus Start");
            var JsonString = File.ReadAllText("../../../Files/GetItems.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemsResponse           Response         = VisualInspection.GetItems();

            Assert.IsTrue(Response.Data.Predict[0].Assessment.Equals("Upload specific status"));
            Assert.IsFalse(Response.Data.Predict[0].ConfirmedAssessment);
            Assert.IsTrue(Response.Data.Predict[0].Date.Equals(DateTime.Parse("Wed, 19 Jun 2019 05:03:09 GMT").ToUniversalTime()));
            Assert.IsTrue(Response.Data.Predict[0].DefaultImage.Equals("https://hacarus-saas-data.s3.amazonaws.com/raw/bc8a33dde2b0f45e2d6340083b5e153f59e33a42"));
            Assert.IsNull(Response.Data.Predict[0].Description);
            Assert.IsTrue(Response.Data.Predict[0].DetectedObjects.Equals(0));
            Assert.IsTrue(Response.Data.Predict[0].DetectionAccuracy.Equals(0));
            Assert.IsTrue(Response.Data.Predict[0].FinishedDate.Equals(DateTime.Parse("Wed, 19 Jun 2019 07:24:42 GMT").ToUniversalTime()));
            Assert.IsTrue((bool)Response.Data.Predict[0].Good);
            Assert.IsFalse(Response.Data.Predict[0].IsTrainingData);
            Assert.IsTrue(Response.Data.Predict[0].ItemId.Equals("0001"));
            Assert.IsTrue(Response.Data.Predict[0].Label.Equals("Job id is 0001"));
            Assert.IsTrue(Response.Data.Predict[0].OverrideAssessment);
            Assert.IsTrue(Response.Data.Predict[0].Status.Equals("done"));
            Assert.IsTrue(Response.Data.Predict[0].ThumbnailImage.Equals("https://hacarus-saas-data.s3.amazonaws.com/thumbnail/bc8a33dde2b0f45e2d6340083b5e153f59e33a42"));
            Console.WriteLine("SuccessPredictGoodStatus End");
        }
Exemple #2
0
        public void SuccessTrainingNullStatus()
        {
            Console.WriteLine("SuccessTrainingNullStatus Start");
            var JsonString = File.ReadAllText("../../../Files/GetItems.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemsResponse           Response         = VisualInspection.GetItems();

            Assert.IsNull(Response.Data.Training[0].Assessment);
            Assert.IsTrue(Response.Data.Training[0].ConfirmedAssessment);
            Assert.IsTrue(Response.Data.Training[0].Date.Equals(DateTime.Parse("Mon, 10 Jun 2019 08:22:02 GMT").ToUniversalTime()));
            Assert.IsTrue(Response.Data.Training[0].DefaultImage.Equals("https://hacarus-saas-data.s3.amazonaws.com/raw/b21d29f794e781e12f466a1fcc1bf1a1596e5320"));
            Assert.IsNull(Response.Data.Training[0].Description);
            Assert.IsTrue(Response.Data.Training[0].DetectionAccuracy.Equals(0));
            Assert.IsTrue(Response.Data.Training[0].DetectedObjects.Equals(0));
            Assert.IsNull(Response.Data.Training[0].FinishedDate);
            Assert.IsNull(Response.Data.Training[0].Good);
            Assert.IsTrue(Response.Data.Training[0].IsTrainingData);
            Assert.IsTrue(Response.Data.Training[0].ItemId.Equals("T1-22-01"));
            Assert.IsTrue(Response.Data.Training[0].Label.Equals("Job id is T1-22-01"));
            Assert.IsTrue(Response.Data.Training[0].OverrideAssessment);
            Assert.IsTrue(Response.Data.Training[0].Status.Equals("pending"));
            Assert.IsTrue(Response.Data.Training[0].ThumbnailImage.Equals("https://hacarus-saas-data.s3.amazonaws.com/thumbnail/b21d29f794e781e12f466a1fcc1bf1a1596e5320"));
            Console.WriteLine("SuccessTrainingNullStatus End");
        }
        public void SuccessManual()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemSuccessManual.txt");
            var Client     = MockGenerator.MockRestClient <ItemResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemResponse            Response         = VisualInspection.GetItem("ItemId");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));

            Assert.IsTrue(Response.Data.ComputedAssessment.AssessmentResult.Equals("[DR] Good product!"));
            Assert.IsTrue(Response.Data.ComputedAssessment.DetectedObjects.Equals(0));
            Assert.IsTrue(Response.Data.ComputedAssessment.DetectionAccuracy.Equals(100.0));
            Assert.IsTrue((bool)Response.Data.ComputedAssessment.Good);

            Assert.IsFalse(Response.Data.ConfirmedAssessment);

            Assert.IsTrue(Response.Data.Images.Count.Equals(1));
            Assert.IsTrue(Response.Data.Images[0].Annotations.Count.Equals(18));
            Assert.IsNotNull(Response.Data.Images[0].ExifMetadata);

            Assert.IsTrue(Response.Data.ManualAssessment.AssessmentResult.Equals("test defect"));
            Assert.IsTrue(Response.Data.ManualAssessment.DetectedObjects.Equals(0));
            Assert.IsNull(Response.Data.ManualAssessment.DetectionAccuracy);
            Assert.IsFalse((bool)Response.Data.ManualAssessment.Good);
            Assert.IsTrue((bool)Response.Data.ManualAssessment.OverrideAssessment);

            Console.WriteLine("Success End");
        }
Exemple #4
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetItems.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemsResponse           Response         = VisualInspection.GetItems();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.Archived.Count.Equals(0));
            Assert.IsTrue(Response.Data.Predict.Count.Equals(1));
            Assert.IsTrue(Response.Data.Training.Count.Equals(1));

            //Summary
            Assert.IsNotNull(Response.Data.Summary);
            Assert.IsTrue(Response.Data.Summary.Adjusted.Equals(0));
            Assert.IsTrue(Response.Data.Summary.Analysed.Equals(0));
            Assert.IsTrue(Response.Data.Summary.ArchivedDefects.Equals(0));
            Assert.IsTrue(Response.Data.Summary.Assessment.Equals("Bad Product"));
            Assert.IsTrue(Response.Data.Summary.Confirmed.Equals(0));
            Assert.IsTrue(Response.Data.Summary.DefectsDetected.Equals(0));
            Assert.IsTrue(Response.Data.Summary.DetectionAccuracy.Equals(0));
            Assert.IsTrue(Response.Data.Summary.ItemsArchived.Equals(0));
            Assert.IsTrue(Response.Data.Summary.ItemsForReview.Equals(0));
            Assert.IsTrue(Response.Data.Summary.Title.Equals("Context #1"));
            Assert.IsTrue(Response.Data.Summary.Training.Good.Equals(1));
            Assert.IsTrue(Response.Data.Summary.Training.Defect.Equals(0));
            Console.WriteLine("Success End");
        }
Exemple #5
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/TrainSuccess.txt");
            var Client     = MockGenerator.MockRestClient <ModelResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ModelResponse           Response         = VisualInspection.Train("OC", "6/11/19 10:26:07 AM", new string[] { "iItemID" }, new AlgorithmParameter[] { });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsFalse(Response.Data.Active);
            Assert.IsTrue(Response.Data.AlgorithmId.Equals("OC"));
            Assert.IsFalse(Response.Data.ContextDefault);
            Assert.IsTrue(Response.Data.ContextId.Equals(1000));
            Assert.IsTrue(Response.Data.CreatedAt.Equals(DateTime.Parse("2019-06-11T01:26:08Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data.ModelId.Equals(270));
            Assert.IsTrue(Response.Data.Name.Equals("6/11/19 10:26:07 AM"));
            Assert.IsTrue(Response.Data.Status.Equals("creating"));
            Assert.IsTrue(Response.Data.UpdatedAt.Equals(DateTime.Parse("2019-06-11T10:26:07Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data.Version.Equals("model-2019061101:26:07"));
            Console.WriteLine("Success End");
        }
Exemple #6
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetAlgorithmsSuccess.txt");
            var Client     = MockGenerator.MockRestClient <AlgorithmResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AlgorithmResponse       Response         = VisualInspection.GetAlgorithms();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data[0].AlgorithmId.Equals("OC"));
            Assert.IsTrue(Response.Data[0].Name.Equals("OC"));
            Assert.IsTrue(Response.Data[0].Parameters.Count.Equals(1));
            Assert.IsTrue(Response.Data[0].Parameters[0].AlgorithmParameterId.Equals(249));
            Assert.IsTrue(Response.Data[0].Parameters[0].CreatedAt.Equals(DateTime.Parse("2019-06-06T23:29:17Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data[0].Parameters[0].DataType.Equals("tuple"));
            Assert.IsTrue(Response.Data[0].Parameters[0].ModelParameter);
            Assert.IsTrue(Response.Data[0].Parameters[0].Name.Equals("patch_size"));
            Assert.IsTrue(Response.Data[0].Parameters[0].UpdatedAt.Equals(DateTime.Parse("2019-06-06T23:30:20Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data[0].Parameters[0].Value.Equals("[4, 4]"));
            Console.WriteLine("Success End");
        }
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemSuccess.txt");
            var Client     = MockGenerator.MockRestClient <ItemResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemResponse            Response         = VisualInspection.GetItem("ItemId");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));

            Assert.IsTrue(Response.Data.ComputedAssessment.AssessmentResult.Equals("[OC] Defected product"));
            Assert.IsTrue(Response.Data.ComputedAssessment.DetectedObjects.Equals(2));
            Assert.IsTrue(Response.Data.ComputedAssessment.DetectionAccuracy.Equals(100.0));
            Assert.IsFalse((bool)Response.Data.ComputedAssessment.Good);

            Assert.IsTrue(Response.Data.ConfirmedAssessment);

            Assert.IsTrue(Response.Data.Images.Count.Equals(1));
            Assert.IsTrue(Response.Data.Images[0].Annotations.Count.Equals(2));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].AnnotationId.Equals(8269));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].CreatedAt.Equals(DateTime.Parse("2019-06-11T05:47:00Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].ImageId.Equals(1805));
            Assert.IsNull(Response.Data.Images[0].Annotations[0].Notes);
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].XMax.Equals(620));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].XMin.Equals(606));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].YMax.Equals(2322));
            Assert.IsTrue(Response.Data.Images[0].Annotations[0].YMin.Equals(2284));

            Assert.IsTrue(Response.Data.Images[0].ContentType.Equals("image/jpeg"));
            Assert.IsTrue(Response.Data.Images[0].DefectCounted.Equals(70));
            Assert.IsTrue(Response.Data.Images[0].ExifMetadata.FocalLengthIn35mmFilm.Equals(29));
            Assert.IsTrue(Response.Data.Images[0].ExifMetadata.GpsInfo["1"].Equals("N"));
            Assert.IsTrue(Response.Data.Images[0].FileSize.Equals(1524794));
            Assert.IsTrue(Response.Data.Images[0].Height.Equals(3024));
            Assert.IsTrue(Response.Data.Images[0].ImageId.Equals(1805));
            Assert.IsTrue(Response.Data.Images[0].IsRawUploaded);
            Assert.IsNull(Response.Data.Images[0].Position);
            Assert.IsTrue(Response.Data.Images[0].Processed);
            Assert.IsTrue(Response.Data.Images[0].RawUrl.Equals("https://hacarus-saas-data.s3.amazonaws.com/raw/d9b6b9709b29d4deb30be4e981031f09823120c7"));
            Assert.IsTrue(Response.Data.Images[0].Url.Equals("https://hacarus-saas-data.s3.amazonaws.com/processed/d9b6b9709b29d4deb30be4e981031f09823120c7"));
            Assert.IsTrue(Response.Data.Images[0].Width.Equals(4032));


            Assert.IsFalse(Response.Data.IsTrainingData);
            Assert.IsTrue(Response.Data.ItemId.Equals("IMG6760_U"));
            Assert.IsTrue(Response.Data.Label.Equals("Job id is IMG6760_U"));
            Assert.IsNull(Response.Data.ManualAssessment.AssessmentResult);
            Assert.IsNull(Response.Data.ManualAssessment.DetectedObjects);
            Assert.IsNull(Response.Data.ManualAssessment.DetectionAccuracy);
            Assert.IsNull(Response.Data.ManualAssessment.Good);
            Assert.IsFalse((bool)Response.Data.ManualAssessment.OverrideAssessment);
            Assert.IsTrue(Response.Data.Status.Equals("done"));

            Console.WriteLine("Success End");
        }
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetVersionNumber.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            VersionResponse         Response         = VisualInspection.GetVersionNumber();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.VersionNumber);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.VersionNumber.Equals("1.0.0.0"));
            Console.WriteLine("Success End");
        }
        public void GetContextJapanese()
        {
            Console.WriteLine("GetContextJapanese Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemsErrorJa.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.NotFound, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client, "ja");
            ItemsResponse           Response         = VisualInspection.GetItems();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.NotFound));
            Assert.IsTrue(Response.Errors.Title.Equals(""));
            Assert.IsTrue(Response.Errors.Details.Equals("\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002"));
            Console.WriteLine("GetContextJapanese End");
        }
Exemple #10
0
        public void FailedClientID()
        {
            Console.WriteLine("FailedClientID Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeFailedClientID.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.Unauthorized, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("InvalidClientId", "ValidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Unauthorized));
            Assert.IsTrue(Response.Errors.Title.Equals("Cannot find client information"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Unauthorized));
            Console.WriteLine("FailedClientID End");
        }
Exemple #11
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeSuccess.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("ValidClientId", "ValidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.AccessToken.Equals("GeneratedAccessToken"));
            Assert.IsTrue(Response.Data.Expires.Equals(2592000));
            Console.WriteLine("Success End");
        }
        public void GetContextEnglishSetLanguage()
        {
            Console.WriteLine("GetContextEnglish Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemsErrorEn.txt");
            var Client     = MockGenerator.MockRestClient <ItemsResponse>(HttpStatusCode.NotFound, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);

            VisualInspection.SetLanguage("en");
            ItemsResponse Response = VisualInspection.GetItems();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.NotFound));
            Assert.IsTrue(Response.Errors.Title.Equals(""));
            Assert.IsTrue(Response.Errors.Details.Equals("Cannot find context"));
            Console.WriteLine("GetContextEnglish End");
        }
Exemple #13
0
        public void FailedInvalidId()
        {
            Console.WriteLine("FailedInvalidId Start");
            var JsonString = File.ReadAllText("../../../Files/TrainFailedInvalidId.txt");
            var Client     = MockGenerator.MockRestClient <ModelResponse>(HttpStatusCode.Forbidden, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ModelResponse           Response         = VisualInspection.Train("OC", "6/11/19 10:26:07 AM", new string[] { "InvalidItemID" }, new AlgorithmParameter[] { });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Forbidden));
            Assert.IsTrue(Response.Errors.Title.Equals("You do not have access to one or more item ids provided"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/train"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Forbidden));
            Console.WriteLine("FailedInvalidId End");
        }
        public void FailedItemIdNoPermission()
        {
            Console.WriteLine("FailedItemIdNoPermission Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemFailedItemIdNoPermission.txt");
            var Client     = MockGenerator.MockRestClient <ItemResponse>(HttpStatusCode.Unauthorized, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemResponse            Response         = VisualInspection.GetItem("NoPermissionItemId");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Unauthorized));
            Assert.IsTrue(Response.Errors.Title.Equals("No permission to view item!"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/item/NoPermissionItemId"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Unauthorized));
            Console.WriteLine("FailedItemIdNoPermission End");
        }
        public void FailedItemIdDoesNotExist()
        {
            Console.WriteLine("FailedItemIdDoesNotExists Start");
            var JsonString = File.ReadAllText("../../../Files/GetItemFailedItemIdDoesNotExist.txt");
            var Client     = MockGenerator.MockRestClient <ItemResponse>(HttpStatusCode.NotFound, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ItemResponse            Response         = VisualInspection.GetItem("invaliditem");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.NotFound));
            Assert.IsTrue(Response.Errors.Title.Equals("No match for item_id!"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/item/invaliditem"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.NotFound));
            Console.WriteLine("FailedItemIdDoesNotExist End");
        }
        public void FailedNoModel()
        {
            Console.WriteLine("FailedNoModel Start");
            var JsonString = File.ReadAllText("../../../Files/PredictFailedNoModel.txt");
            var Client     = MockGenerator.MockRestClient <UploadResponse>(HttpStatusCode.BadRequest, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            PredictResponse         Response         = VisualInspection.Serve(new string[] { "NewItem" });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.BadRequest));
            Assert.IsTrue(Response.Errors.Title.Equals("There is no available model"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/serve"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.BadRequest));
            Console.WriteLine("FailedItemIdDoesNotExists End");
        }
        public void FailedInvalidLicenseFile()
        {
            Console.WriteLine("FailedInvalidLicenseFile Start");
            var JsonString = File.ReadAllText("../../../Files/ActivateLicenseFailed.txt");
            var Client     = MockGenerator.MockRestClient <LicenseResponse>(HttpStatusCode.Forbidden, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            var LicenseFile = new FileModel("../../../Files/license0", "txt");

            LicenseResponse Response = VisualInspection.ActivateLicense(LicenseFile);

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNull(Response.Data);
            Assert.IsNotNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Forbidden));
            Assert.IsTrue(Response.Errors.Title.Equals("Invalid license!"));
            Console.WriteLine("FailedInvalidLicenseFile End");
        }
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/ActivateLicenseSuccess.txt");
            var Client     = MockGenerator.MockRestClient <LicenseResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            var LicenseFile = new FileModel("../../../Files/license0", "txt");

            LicenseResponse Response = VisualInspection.ActivateLicense(LicenseFile);

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.Status.Equals("ok"));
            Console.WriteLine("Success End");
        }
Exemple #19
0
        public void FailedClientSecret()
        {
            Console.WriteLine("FailedClientSecret Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeFailedClientSecret.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.Unauthorized, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("ValidClientId", "InvalidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Unauthorized));
            Assert.IsTrue(Response.Errors.Title.Equals("Client id and secret mismatch"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/auth/token"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Unauthorized));
            Console.WriteLine("FailedClientSecret End");
        }
Exemple #20
0
        public void FailedNoAlgorithm()
        {
            Console.WriteLine("FailedNoAlgorithm Start");
            var JsonString = File.ReadAllText("../../../Files/GetAlgorithmsFailedNoAlgorithm.txt");
            var Client     = MockGenerator.MockRestClient <AlgorithmResponse>(HttpStatusCode.NotFound, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AlgorithmResponse       Response         = VisualInspection.GetAlgorithms();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.NotFound));
            Assert.IsTrue(Response.Errors.Title.Equals("No algorithms found"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/algorithms"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.NotFound));
            Console.WriteLine("FailedNoAlgorithm End");
        }
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/PredictSuccess.txt");
            var Client     = MockGenerator.MockRestClient <PredictResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);

            PredictResponse Response = VisualInspection.Serve(new string[] { "NewItem" });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.ItemIds.Count.Equals(1));
            Assert.IsTrue(Response.Data.ItemIds[0].Equals("NewItem"));
            Assert.IsTrue(Response.Data.ModelVersion.Equals("model-2019061101:26:07"));
            Console.WriteLine("Success End");
        }
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/UploadSuccess.txt");
            var Client     = MockGenerator.MockRestClient <UploadResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);

            var            file     = new FileModel("../../../Files/NewItem.JPG", "jpg");
            UploadResponse Response = VisualInspection.Upload(new List <FileModel> {
                file
            });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);;
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.ItemIds.Count.Equals(1));
            Assert.IsTrue(Response.Data.ItemIds[0].Equals("NewItem"));
            Console.WriteLine("Success End");
        }
        public void FailedNoFile()
        {
            Console.WriteLine("FailedNoFile Start");
            var JsonString = File.ReadAllText("../../../Files/UploadFailedNoFile.txt");
            var Client     = MockGenerator.MockRestClient <UploadResponse>(HttpStatusCode.BadRequest, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);

            UploadResponse Response = VisualInspection.Upload(new List <FileModel> {
            });

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.BadRequest));
            Assert.IsTrue(Response.Errors.Title.Equals("No images to upload"));
            Assert.IsNull(Response.Errors.Details);
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/upload"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.BadRequest));
            Console.WriteLine("FailedNoFile End");
        }
Exemple #24
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/GetModels.txt");
            var Client     = MockGenerator.MockRestClient <ModelsResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            ModelsResponse          Response         = VisualInspection.GetModels();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.Count.Equals(1));
            Assert.IsTrue(Response.Data[0].Active);
            Assert.IsTrue(Response.Data[0].AlgorithmId.Equals("OC"));
            Assert.IsFalse(Response.Data[0].ContextDefault);
            Assert.IsTrue(Response.Data[0].CreatedAt.Equals(DateTime.Parse("2019-06-10T08:28:16Z").ToUniversalTime()));
            Assert.IsTrue(Response.Data[0].ModelId.Equals(269));
            Assert.IsTrue(Response.Data[0].Name.Equals("Test-20190610-01"));
            Assert.IsTrue(Response.Data[0].Status.Equals("active"));
            Assert.IsTrue(Response.Data[0].Version.Equals("model-2019061008:28:16"));
            Console.WriteLine("Success End");
        }