public void AddImageTest() { IModeratorService moderatorService = new ModeratorService(this.serviceOptions); // Add Image (with labels) // See label details in the response documentation: https://developer.microsoftmoderator.com/docs/services/54f7932727037412a0cda396/operations/54f793272703740c70627a24 using (Stream stream = new FileStream(TestImageContent, FileMode.Open, FileAccess.Read)) { ImageModeratableContent imageContent = new ImageModeratableContent(new BinaryContent(stream, "image/jpeg")); var addResponse = moderatorService.ImageAddAsync(imageContent); var addResult = addResponse.Result; Assert.IsTrue(addResult != null, "Expected valid result, Response: {0}", JsonConvert.SerializeObject(addResult)); Assert.IsTrue(string.IsNullOrWhiteSpace(addResult.ImageId) || string.Compare(addResult.Status.Description, "Error occurred while processing request :: Failure Adding a valid image :: Image already exists") == 0, "Image Id can be null only if the Image already exists, Response: {0}", JsonConvert.SerializeObject(addResult)); // Refresh index var refreshResponse = moderatorService.RefreshImageIndexAsync(); var refreshResult = refreshResponse.Result; Assert.IsTrue(refreshResult.IsUpdateSuccess, "Expected update Success on refresh, Response: {0}", JsonConvert.SerializeObject(refreshResult)); } using (Stream stream = new FileStream(TestImageContent, FileMode.Open, FileAccess.Read)) { ImageModeratableContent imageContent = new ImageModeratableContent(new BinaryContent(stream, "image/jpeg")); // Match var matchResponse = moderatorService.MatchImageAsync(imageContent); var matchResult = matchResponse.Result; Assert.IsTrue(matchResult.IsMatch, "Expected match, Response: {0}", JsonConvert.SerializeObject(matchResult)); } }