public void TestDetectLabelsForValidResponse() { var sample = new GoogleCloudSamples.LabelDetectionSample(); VisionService vision = sample.CreateAuthorizedClient(); var result = sample.DetectLabels(vision, @"..\..\..\data\cat.jpg"); // Confirm that DetectLabels returns expected result for test image. var response = result[0]; var label = response.LabelAnnotations[0]; Assert.IsNotNull(label.Description); Assert.IsTrue(label.Description.Contains("cat")); }
public void TestDetectLabelsForInvalidImage() { var sample = new GoogleCloudSamples.LabelDetectionSample(); VisionService vision = sample.CreateAuthorizedClient(); // Confirm invalid image doesn't get labels and throws an exception var result = sample.DetectLabels(vision, @"..\..\..\data\bad.txt"); var response = result[0]; var label = response.LabelAnnotations[0]; if (!String.IsNullOrEmpty(label.Description)) { Assert.Fail(); } }