Ejemplo n.º 1
0
        public SpeechModelSet GetModels()
        {
            SpeechModelSet result = null;

            try
            {
                result =
                    this.Client.WithAuthentication(this.UserName, this.Password)
                    .GetAsync($"{RELATIVE_PATH}{PATH_MODELS}")
                    .As <SpeechModelSet>()
                    .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public SpeechModelSet GetModels()
        {
            SpeechModelSet result = null;

            try
            {
                result =
                    this.Client.WithAuthentication(this.UserName, this.Password)
                    .GetAsync($"{this.Endpoint}{PATH_MODELS}")
                    .As <SpeechModelSet>()
                    .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.InnerException as ServiceResponseException;
            }

            return(result);
        }
        public void GetModel_Sucess()
        {
            #region Mock IClient

            IClient client = Substitute.For <IClient>();

            client.WithAuthentication(Arg.Any <string>(), Arg.Any <string>())
            .Returns(client);

            SpeechModelSet response = new SpeechModelSet()
            {
                Models = new List <SpeechModel>()
                {
                    new SpeechModel()
                    {
                        Description = "TEST",
                        Language    = "pt-br",
                        Name        = "UNIT_TEST",
                        Rate        = 1,
                        Sessions    = Guid.NewGuid().ToString(),
                        Url         = "http://"
                    }
                }
            };

            IRequest request = Substitute.For <IRequest>();
            client.GetAsync(Arg.Any <string>())
            .Returns(request);

            request.As <SpeechModelSet>()
            .Returns(Task.FromResult(response));

            #endregion

            SpeechToTextService service = new SpeechToTextService(client);

            var models = service.GetModels();

            Assert.IsNotNull(models);
            client.Received().GetAsync(Arg.Any <string>());
            Assert.IsTrue(models.Models.Count > 0);
        }