private void AddCollectionImageMetadata()
        {
            if (string.IsNullOrEmpty(_createdCollectionId))
            {
                throw new ArgumentNullException(nameof(_createdCollectionId));
            }

            if (string.IsNullOrEmpty(_addedImageId))
            {
                throw new ArgumentNullException(nameof(_addedImageId));
            }

            using (FileStream metadataStream = File.OpenRead(_localImageMetadataPath))
            {
                Console.WriteLine(string.Format("\nCalling AddMetadata(\"{0}\", \"{1}\")...", _createdCollectionId, _addedImageId));

                var result = _visualRecognition.AddImageMetadata(_createdCollectionId, _addedImageId, metadataStream.ReadAllBytes());

                if (result != null && result.Count > 0)
                {
                    foreach (KeyValuePair <string, string> kvp in result)
                    {
                        Console.WriteLine("\t{0} : {1}", kvp.Key, kvp.Value);
                    }
                }
                else
                {
                    Console.WriteLine("Result is null.");
                }
            }
        }
Ejemplo n.º 2
0
        public void t16_AddCollectionImageMetadata_Success()
        {
            if (string.IsNullOrEmpty(_createdCollectionId))
                Assert.Fail("Created collection ID is null or empty.");

            if (string.IsNullOrEmpty(_addedImageId))
                Assert.Fail("Added image ID is null or empty.");

            VisualRecognitionService service = new VisualRecognitionService();
            service.SetCredential(apikey);

            using (FileStream metadataStream = File.OpenRead(_localImageMetadataPath))
            {
                var result = service.AddImageMetadata(_createdCollectionId, _addedImageId, metadataStream.ReadAllBytes());

                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 0);
            }
        }