public void GetFullRecordingUriSuccess()
        {
            InitializeSecrets();

            string expectedCallSid              = "CA10000000000000000000000000000010";
            string expectedRecordingSid         = "RE10000000000000000000000000000005";
            string expectedRecordingRelativeUri = $"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings/{expectedRecordingSid}";
            string expectedRecordingUri         = $"{TwilioCallWrapper.TwilioUriBase}{expectedRecordingRelativeUri}";

            RecordingResource recording = RecordingResource.FromJson(
                TemplateManager.Load(RecordingCompositeTemplatePath, new Dictionary <string, string>()
            {
                { "accountSid", TestAccountSid },
                { "callSid", expectedCallSid },
                { "recordingSid", expectedRecordingSid },
                { "recordingUri", expectedRecordingRelativeUri },
            }));

            TwilioCallWrapper callWrapper = Container.GetService <ITwilioCallWrapper>() as TwilioCallWrapper;

            Uri recordingUri = callWrapper.GetFullRecordingUri(recording, Log);

            Assert.IsNotNull(recordingUri);
            Assert.AreEqual(expectedRecordingUri, recordingUri.AbsoluteUri);
        }
Exemplo n.º 2
0
        public void GivenAnIndexAction_WhenClientHasRecordings_ThenShowsTheRecordings()
        {
            var mockClient = new Mock <IClient>();

            var recordingsFromApi = new List <RecordingResource>
            {
                RecordingResource.FromJson("{\"date_created\": \"Mon, 22 Aug 2011 20:58:45 +0000\", \"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}")
            };

            mockClient.Setup(c => c.Recordings()).ReturnsAsync(recordingsFromApi);

            var stubPhoneNumbers = Mock.Of <IPhoneNumbers>();
            var controller       = new RecordingsController(mockClient.Object, stubPhoneNumbers);
            var result           = controller.WithCallTo(c => c.Index()).ShouldReturnJson();
            var recordings       = (result.Data as IEnumerable <object>).ToList();

            Assert.That(recordings.Count(), Is.EqualTo(1));
        }