コード例 #1
0
 /// <summary>
 /// Delete the incoming message.
 /// </summary>
 /// <param name="reply">Reply object</param>
 /// <returns></returns>
 public DeleteResult DeleteReply(Reply reply)
 {
     return DeleteReply(reply.Id);
 }
コード例 #2
0
        public void ShouldDeleteReply()
        {
            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 reply = new Reply()
            {
                Id = replyId
            };

            client.DeleteReply(reply);

            mockClient.Verify(trc => trc.Execute<DeleteResult>(It.IsAny<IRestRequest>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("replies/{id}", savedRequest.Resource);
            Assert.AreEqual(Method.DELETE, savedRequest.Method);
            Assert.AreEqual(1, savedRequest.Parameters.Count);
            Assert.AreEqual(replyId.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.DeleteReply(reply);

            Assert.IsTrue(result.Success);
        }