public void CheckMessageIsSent() { var twilioWrapper = MockRepository.GenerateMock<ITwilioWrapper>(); const string sid = "sid"; twilioWrapper .Expect(t => t.CheckMessage(sid)) .Return(new SMSMessage { Sid = sid, Status = "sent" }); var smsService = new SmsService { TwilioWrapper = twilioWrapper }; var smsStatus = smsService.CheckStatus(sid); Assert.That(smsStatus, Is.TypeOf(typeof(SmsSent))); Assert.That(smsStatus.Sid, Is.EqualTo(sid)); twilioWrapper.VerifyAllExpectations(); }
public void SmsServiceSending() { var messageToSend = new SendOneMessageNow { SmsData = new SmsData("mobile", "message") }; var twilioWrapper = MockRepository.GenerateMock<ITwilioWrapper>(); var smsService = new SmsService { TwilioWrapper = twilioWrapper }; var smsMessageSending = new SMSMessage { Status = "sending", Sid = "sidReceipt" }; twilioWrapper .Expect(t => t.SendSmsMessage(messageToSend.SmsData.Mobile, messageToSend.SmsData.Message)) .Return(smsMessageSending); var response = smsService.Send(messageToSend); Assert.That(response, Is.TypeOf(typeof (SmsSending))); Assert.That(response.Sid, Is.EqualTo(smsMessageSending.Sid)); twilioWrapper.VerifyAllExpectations(); }
public void SmsServiceRestException() { var messageToSend = new SendOneMessageNow { SmsData = new SmsData("mobile", "message") }; var twilioWrapper = MockRepository.GenerateMock<ITwilioWrapper>(); var smsService = new SmsService { TwilioWrapper = twilioWrapper }; var smsMessageSending = new SMSMessage { RestException = new RestException {Code = "code", Message = "message", MoreInfo = "moreInfo", Status = "status"}}; twilioWrapper .Expect(t => t.SendSmsMessage(messageToSend.SmsData.Mobile, messageToSend.SmsData.Message)) .Return(smsMessageSending); var response = smsService.Send(messageToSend); Assert.That(response, Is.TypeOf(typeof(SmsFailed))); Assert.That(response.Sid, Is.EqualTo(smsMessageSending.Sid)); var smsFailed = response as SmsFailed; Assert.That(smsFailed.Status, Is.EqualTo(smsMessageSending.RestException.Status)); Assert.That(smsFailed.Code, Is.EqualTo(smsMessageSending.RestException.Code)); Assert.That(smsFailed.Message, Is.EqualTo(smsMessageSending.RestException.Message)); Assert.That(smsFailed.MoreInfo, Is.EqualTo(smsMessageSending.RestException.MoreInfo)); twilioWrapper.VerifyAllExpectations(); }
public void SmsServiceSuccess() { var messageToSend = new SendOneMessageNow { SmsData = new SmsData("mobile", "message")}; var twilioWrapper = MockRepository.GenerateMock<ITwilioWrapper>(); var smsService = new SmsService { TwilioWrapper = twilioWrapper }; var smsMessage = new SMSMessage { Status = "sent", Sid = "sidReceipt", DateSent = DateTime.Now, Price = 3 }; twilioWrapper .Expect(t => t.SendSmsMessage(messageToSend.SmsData.Mobile, messageToSend.SmsData.Message)) .Return(smsMessage); var response = smsService.Send(messageToSend); Assert.That(response, Is.TypeOf(typeof(SmsSent))); Assert.That(response.Sid, Is.EqualTo(smsMessage.Sid)); var smsSent = response as SmsSent; Assert.That(smsSent.SmsConfirmationData.Receipt, Is.EqualTo(smsMessage.Sid)); Assert.That(smsSent.SmsConfirmationData.SentAtUtc, Is.EqualTo(smsMessage.DateSent)); Assert.That(smsSent.SmsConfirmationData.Price, Is.EqualTo(smsMessage.Price)); twilioWrapper.VerifyAllExpectations(); }