示例#1
0
        public async Task CreateCallWithMachineDetectionReturnsCreated()
        {
            var accountId     = TestConstants.AccountId;
            var to            = TestConstants.To;
            var from          = TestConstants.From;
            var applicationId = TestConstants.VoiceApplicationId;
            var answerUrl     = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");
            var machineDetectionConfiguration = new MachineDetectionConfiguration()
            {
                CallbackUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/machine-detection")
            };

            var request = new CreateCallRequest()
            {
                ApplicationId    = applicationId,
                To               = to,
                From             = from,
                AnswerUrl        = answerUrl,
                MachineDetection = machineDetectionConfiguration
            };

            var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);

            Assert.Equal(201, createCallResponse.StatusCode);

            Assert.Equal(accountId, createCallResponse.Data.AccountId);
            Assert.Equal(applicationId, createCallResponse.Data.ApplicationId);
            Assert.Equal(to, createCallResponse.Data.To);
            Assert.Equal(from, createCallResponse.Data.From);
            Assert.True(Uri.IsWellFormedUriString(createCallResponse.Data.CallUrl, UriKind.Absolute));
            Assert.Equal(answerUrl, createCallResponse.Data.AnswerUrl);
            Assert.Equal(AnswerMethodEnum.POST, createCallResponse.Data.AnswerMethod);
            Assert.Equal(DisconnectMethodEnum.POST, createCallResponse.Data.DisconnectMethod);
        }
示例#2
0
        public void SerializeMachineDetectionConfiguration()
        {
            var machineDetectionConfiguration = new MachineDetectionConfiguration
            {
                Mode                      = ModeEnum.Async,
                DetectionTimeout          = 3.2,
                SilenceTimeout            = 5.6,
                SpeechThreshold           = 1.2,
                SpeechEndThreshold        = 7.6,
                DelayResult               = false,
                CallbackUrl               = "https://www.example.com/",
                CallbackMethod            = CallbackMethodEnum.GET,
                FallbackUrl               = "https://www.example-fallback.com/",
                FallbackMethod            = FallbackMethodEnum.GET,
                Username                  = "******",
                Password                  = "******",
                FallbackUsername          = "******",
                FallbackPassword          = "******",
                MachineSpeechEndThreshold = 3.4
            };

            var json = JsonConvert.SerializeObject(machineDetectionConfiguration);

            Assert.Equal("{\"machineSpeechEndThreshold\":3.4,\"mode\":\"async\",\"detectionTimeout\":3.2,\"silenceTimeout\":5.6,\"speechThreshold\":1.2,\"speechEndThreshold\":7.6,\"delayResult\":false,\"callbackUrl\":\"https://www.example.com/\",\"callbackMethod\":\"GET\",\"fallbackUrl\":\"https://www.example-fallback.com/\",\"fallbackMethod\":\"GET\",\"username\":\"neato-username\",\"password\":\"neato-password\",\"fallbackUsername\":\"neato-username-fallback\",\"fallbackPassword\":\"neato-password-fallback\"}", json);
        }
示例#3
0
        public void PopulateMachineDetectionConfiguration()
        {
            var machineDetectionConfiguration = new MachineDetectionConfiguration
            {
                Mode                      = ModeEnum.Async,
                DetectionTimeout          = 3.2,
                SilenceTimeout            = 5.6,
                SpeechThreshold           = 1.2,
                SpeechEndThreshold        = 7.6,
                DelayResult               = false,
                CallbackUrl               = "https://www.example.com/",
                CallbackMethod            = CallbackMethodEnum.GET,
                FallbackUrl               = "https://www.example-fallback.com/",
                FallbackMethod            = FallbackMethodEnum.GET,
                Username                  = "******",
                Password                  = "******",
                FallbackUsername          = "******",
                FallbackPassword          = "******",
                MachineSpeechEndThreshold = 3.4
            };

            Assert.Equal(ModeEnum.Async, machineDetectionConfiguration.Mode);
            Assert.Equal(3.2, machineDetectionConfiguration.DetectionTimeout);
            Assert.Equal(5.6, machineDetectionConfiguration.SilenceTimeout);
            Assert.Equal(1.2, machineDetectionConfiguration.SpeechThreshold);
            Assert.Equal(7.6, machineDetectionConfiguration.SpeechEndThreshold);
            Assert.False(machineDetectionConfiguration.DelayResult);
            Assert.Equal("https://www.example.com/", machineDetectionConfiguration.CallbackUrl);
            Assert.Equal(CallbackMethodEnum.GET, machineDetectionConfiguration.CallbackMethod);
            Assert.Equal("https://www.example-fallback.com/", machineDetectionConfiguration.FallbackUrl);
            Assert.Equal(FallbackMethodEnum.GET, machineDetectionConfiguration.FallbackMethod);
            Assert.Equal("neato-username", machineDetectionConfiguration.Username);
            Assert.Equal("neato-password", machineDetectionConfiguration.Password);
            Assert.Equal("neato-username-fallback", machineDetectionConfiguration.FallbackUsername);
            Assert.Equal("neato-password-fallback", machineDetectionConfiguration.FallbackPassword);
            Assert.Equal(3.4, machineDetectionConfiguration.MachineSpeechEndThreshold);
        }