public void EvaluateImageContentTest() { using (Stream stream = new FileStream(TestImageContent, FileMode.Open, FileAccess.Read)) { IModeratorService moderatorService = new ModeratorService(this.serviceOptions); ImageModeratableContent imageContent = new ImageModeratableContent(new BinaryContent(stream, "image/jpeg")); var moderateResult = moderatorService.EvaluateImageAsync(imageContent); var actualResult = moderateResult.Result; Assert.IsTrue(actualResult != null, "Expected valid result, Response: {0}", JsonConvert.SerializeObject(actualResult)); Assert.IsTrue(actualResult.AdvancedInfo != null, "Expected valid result, Response: {0}", JsonConvert.SerializeObject(actualResult)); var score = actualResult.AdvancedInfo.First( x => string.Equals(x.Key, "score", StringComparison.OrdinalIgnoreCase)); double scoreValue = double.Parse(score.Value); Assert.IsTrue(scoreValue > 0, "Expected higher than 0 score value for test image, Response: {0}", JsonConvert.SerializeObject(actualResult)); } }
public void EvaluateImageUrlTest() { IModeratorService moderatorService = new ModeratorService(this.serviceOptions); ImageModeratableContent imageContent = new ImageModeratableContent(TestImageUrl); var moderateResult = moderatorService.EvaluateImageAsync(imageContent); var actualResult = moderateResult.Result; Assert.IsTrue(actualResult != null, "Expected valid result, Response: {0}", JsonConvert.SerializeObject(actualResult)); Assert.IsTrue(actualResult.AdvancedInfo != null, "AdvancedInfo is NULL, Response: {0}", JsonConvert.SerializeObject(actualResult)); var score = actualResult.AdvancedInfo.First(x => string.Equals(x.Key, "score", StringComparison.OrdinalIgnoreCase)); Assert.AreNotEqual("0.000", score.Value, "score value, Response: {0}", JsonConvert.SerializeObject(actualResult)); }