Exemple #1
0
        public void FromImagePath_WhenInvalidImagePath_ReturnNull()
        {
            // Arrange
            var imageFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "invalid-image-path.jpg");

            // Act
            var actual = ByteArrayBuilder.FromImagePath(imageFilePath);

            // Assert
            Assert.IsNull(actual);
        }
Exemple #2
0
        public void FromImagePath_WhenValidImagePath_ReturnByteArray()
        {
            // Arrange
            var imageFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "oberyn-wear-helmet.jpg");

            // Act
            var actual = ByteArrayBuilder.FromImagePath(imageFilePath);

            // Assert
            Assert.IsInstanceOfType(actual, typeof(byte[]));
        }
        public void GetEmotionConfiguration_WhenValidLocalImagePath_ReturnValidConfig()
        {
            // Arrange
            string imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "oberyn-wear-helmet.jpg");
            var    expected  = new RequestConfiguration(
                Uri: "https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize",
                Data: ByteArrayBuilder.FromImagePath(imagePath),
                ContentType: "application/octet-stream",
                CredentialKey: Credentials.EmotionKey);

            // Act
            var actual = req.GetEmotionConfiguration(imagePath);

            // Assert
            Assert.IsInstanceOfType(actual, typeof(RequestConfiguration));
            Assert.AreEqual(expected.ContentType, actual.ContentType);
            Assert.AreEqual(expected.CredentialKey, actual.CredentialKey);
            Assert.IsTrue(expected.Data.SequenceEqual(actual.Data));
            Assert.AreEqual(expected.Uri, actual.Uri);
        }