<commit_before>/**
* Copyright 2018 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using IBM.WatsonDeveloperCloud.TextToSpeech.v1.Model;
using IBM.WatsonDeveloperCloud.Util;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Threading.Tasks;

namespace IBM.WatsonDeveloperCloud.TextToSpeech.v1.IntegrationTests
{
    [TestClass]
    public class TextToSpeechServiceIntegrationTests
    {
        private static string _username;
        private static string _password;
        private static string _endpoint;
        private TextToSpeechService _service;
        private static string credentials = string.Empty;
        private const string _allisonVoice = "en-US_AllisonVoice";
        private string _synthesizeText = "Hello, welcome to the Watson dotnet SDK!";
        private string _voiceModelName = "dotnet-sdk-voice-model";
        private string _voiceModelUpdatedName = "dotnet-sdk-voice-model-updated";
        private string _voiceModelDescription = "Custom voice model for .NET SDK integration tests.";
        private string _voiceModelUpdatedDescription = "Custom voice model for .NET SDK integration tests. Updated.";

        [TestInitialize]
        public void Setup()
        {
            if (string.IsNullOrEmpty(credentials))
            {
                try
                {
                    credentials = Utility.SimpleGet(
                        Environment.GetEnvironmentVariable("VCAP_URL"),
                        Environment.GetEnvironmentVariable("VCAP_USERNAME"),
                        Environment.GetEnvironmentVariable("VCAP_PASSWORD")).Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("Failed to get credentials: {0}", e.Message));
                }

                Task.WaitAll();

                var vcapServices = JObject.Parse(credentials);
                _endpoint = vcapServices["text_to_speech"]["url"].Value<string>();
                _username = vcapServices["text_to_speech"]["username"].Value<string>();
                _password = vcapServices["text_to_speech"]["password"].Value<string>();
            }

            _service = new TextToSpeechService(_username, _password);
            _service.Endpoint = _endpoint;
        }

        #region Voices
        [TestMethod]
        public void Voices_Success()
        {
            var listVoicesResult = ListVoices();

            var getVoiceResult = GetVoice(_allisonVoice);


            Assert.IsNotNull(getVoiceResult);
            Assert.IsTrue(!string.IsNullOrEmpty(getVoiceResult.Name));
            Assert.IsNotNull(listVoicesResult);
            Assert.IsNotNull(listVoicesResult._Voices);
        }
        #endregion

        #region Synthesize
        [TestMethod]
        public void Synthesize_Success()
        {
            Text synthesizeText = new Text
            {
                _Text = _synthesizeText
            };

            var synthesizeResult = Synthesize(synthesizeText, "audio/wave");

            Assert.IsNotNull(synthesizeResult);
        }
        #endregion

        #region Pronunciation
        [TestMethod]
        public void Pronunciation_Success()
        {
            var getPronunciationResult = GetPronunciation("IBM");

            Assert.IsNotNull(getPronunciationResult);
        }<commit_msg>misspelling of wav in integration tests<commit_after>/**
* Copyright 2018 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using IBM.WatsonDeveloperCloud.TextToSpeech.v1.Model;
using IBM.WatsonDeveloperCloud.Util;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Threading.Tasks;

namespace IBM.WatsonDeveloperCloud.TextToSpeech.v1.IntegrationTests
{
    [TestClass]
    public class TextToSpeechServiceIntegrationTests
    {
        private static string _username;
        private static string _password;
        private static string _endpoint;
        private TextToSpeechService _service;
        private static string credentials = string.Empty;
        private const string _allisonVoice = "en-US_AllisonVoice";
        private string _synthesizeText = "Hello, welcome to the Watson dotnet SDK!";
        private string _voiceModelName = "dotnet-sdk-voice-model";
        private string _voiceModelUpdatedName = "dotnet-sdk-voice-model-updated";
        private string _voiceModelDescription = "Custom voice model for .NET SDK integration tests.";
        private string _voiceModelUpdatedDescription = "Custom voice model for .NET SDK integration tests. Updated.";

        [TestInitialize]
        public void Setup()
        {
            if (string.IsNullOrEmpty(credentials))
            {
                try
                {
                    credentials = Utility.SimpleGet(
                        Environment.GetEnvironmentVariable("VCAP_URL"),
                        Environment.GetEnvironmentVariable("VCAP_USERNAME"),
                        Environment.GetEnvironmentVariable("VCAP_PASSWORD")).Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("Failed to get credentials: {0}", e.Message));
                }

                Task.WaitAll();

                var vcapServices = JObject.Parse(credentials);
                _endpoint = vcapServices["text_to_speech"]["url"].Value<string>();
                _username = vcapServices["text_to_speech"]["username"].Value<string>();
                _password = vcapServices["text_to_speech"]["password"].Value<string>();
            }

            _service = new TextToSpeechService(_username, _password);
            _service.Endpoint = _endpoint;
        }

        #region Voices
        [TestMethod]
        public void Voices_Success()
        {
            var listVoicesResult = ListVoices();

            var getVoiceResult = GetVoice(_allisonVoice);


            Assert.IsNotNull(getVoiceResult);
            Assert.IsTrue(!string.IsNullOrEmpty(getVoiceResult.Name));
            Assert.IsNotNull(listVoicesResult);
            Assert.IsNotNull(listVoicesResult._Voices);
        }
        #endregion

        #region Synthesize
        [TestMethod]
        public void Synthesize_Success()
        {
            Text synthesizeText = new Text
            {
                _Text = _synthesizeText
            };

            var synthesizeResult = Synthesize(synthesizeText, "audio/wav");

            Assert.IsNotNull(synthesizeResult);
        }
        #endregion

        #region Pronunciation
        [TestMethod]
        public void Pronunciation_Success()
        {
            var getPronunciationResult = GetPronunciation("IBM");

            Assert.IsNotNull(getPronunciationResult);
        }
{'fraction_non_alphanumeric': 0.08086660788512406, 'fraction_numerical': 0.0027711298652223202, 'mean_word_length': 2.3361344537815127, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '145919', 'n_tokens_mistral': 2062, 'n_tokens_neox': 1926, 'n_words': 513}