public async Task LookupNumber_ReturnsVoipType_WhenResponseIncludesVoipCarrier() { var options = new Mock <IOptions <TwilioSettings> >(); options.Setup(x => x.Value).Returns(new TwilioSettings { Sid = "123", Token = "ABC", PhoneNo = "1234567890" }); var twilioWrapper = new Mock <ITwilioWrapper>(); twilioWrapper.Setup(x => x.FetchPhoneNumberResource(It.IsAny <FetchPhoneNumberOptions>(), It.IsAny <ITwilioRestClient>())) .ReturnsAsync(PhoneNumberResource.FromJson(TwilioResponseJsonVoip)); var sut = new TwilioPhoneNumberLookupService(options.Object, twilioWrapper.Object); var result = await sut.LookupNumber("123456789", "us"); result.Type.ShouldBe(PhoneNumberType.Voip); }
public async Task LookupNumber_ReturnsCorrectPhoneNumberInResult() { var options = new Mock <IOptions <TwilioSettings> >(); options.Setup(x => x.Value).Returns(new TwilioSettings { Sid = "123", Token = "ABC", PhoneNo = "1234567890" }); var twilioWrapper = new Mock <ITwilioWrapper>(); twilioWrapper.Setup(x => x.FetchPhoneNumberResource(It.IsAny <FetchPhoneNumberOptions>(), It.IsAny <ITwilioRestClient>())) .ReturnsAsync(PhoneNumberResource.FromJson(TwilioResponseJson)); var sut = new TwilioPhoneNumberLookupService(options.Object, twilioWrapper.Object); var result = await sut.LookupNumber("123456789", "us"); result.PhoneNumberE164.ToString().ShouldBe(new Twilio.Types.PhoneNumber("+15108675309").ToString()); }