public void SendMessages_WithSmsMessage_ReturnsBatchIdResult() { // Arrange SmsMessage message = new SmsMessage("recipients", "body", "accountReference"); SmsMessageCollection messages = new SmsMessageCollection(message); string serialisedMessage = "serialisedMessage"; RestResource resource = new MessageDispatcherResource(serialisedMessage, false); RestResponse response = new RestResponse() { StatusCode = HttpStatusCode.OK, Content = "serialisedResponse" }; MessagingResult expectedResult = new MessagingResult() { BatchId = Guid.NewGuid(), MessageIds = new List<ResourceLink>() }; mockSerialiser .Setup(s => s.Serialise(messages)) .Returns(serialisedMessage); mockRestClient .Setup(rc => rc.Post(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise<MessagingResult>(response.Content)) .Returns(expectedResult); // Act MessagingResult actualResult = service.SendMessages(messages); // Assert Assert.IsNotNull(actualResult); Assert.AreEqual(expectedResult.BatchId, actualResult.BatchId); Assert.AreEqual(0, actualResult.MessageIds.Count()); }
public void SendScheduledMessages_WithVoiceMessage_ReturnsBatchIdResult() { // Arrange var timestamp = DateTime.UtcNow; var message = new VoiceMessage("recipients", "body", "accountReference"); var messages = new VoiceMessageCollection(message) {SendAt = timestamp}; var serialisedMessage = "serialisedMessage"; RestResource resource = new MessageDispatcherResource(serialisedMessage, false); var response = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "serialisedResponse" }; var expectedResult = new MessagingResult { BatchId = Guid.NewGuid(), MessageIds = new List<ResourceLink>() }; mockSerialiser .Setup(s => s.Serialise(messages)) .Returns(serialisedMessage); mockRestClient .Setup(rc => rc.Post(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise<MessagingResult>(response.Content)) .Returns(expectedResult); // Act var actualResult = service.SendScheduledMessages(messages, timestamp); // Assert Assert.IsNotNull(actualResult); Assert.AreEqual(expectedResult.BatchId, actualResult.BatchId); Assert.AreEqual(0, actualResult.MessageIds.Count()); }