public void ShouldDeleteMessage() { IRestRequest savedRequest = null; mockClient.Setup(trc => trc.Execute<DeleteResult>(It.IsAny<IRestRequest>())) .Callback<IRestRequest>((request) => savedRequest = request) .Returns(new DeleteResult()); var client = mockClient.Object; var message = new Message() { Id = messageId }; client.DeleteMessage(message); mockClient.Verify(trc => trc.Execute<DeleteResult>(It.IsAny<IRestRequest>()), Times.Once); Assert.IsNotNull(savedRequest); Assert.AreEqual("messages/{id}", savedRequest.Resource); Assert.AreEqual(Method.DELETE, savedRequest.Method); Assert.AreEqual(1, savedRequest.Parameters.Count); Assert.AreEqual(messageId.ToString(), savedRequest.Parameters.Find(x => x.Name == "id").Value); var content = "{}"; var testClient = Common.CreateClient<DeleteResult>(content, null, null); client = new Client(testClient); var result = client.DeleteMessage(message); Assert.IsTrue(result.Success); }
/// <summary> /// Delete a single message. /// </summary> /// <param name="message"></param> /// <returns></returns> public DeleteResult DeleteMessage(Message message) { return DeleteMessage(message.Id); }