Exemple #1
0
        public void ResendThroughResponseObjectTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                var dictBody = TestingUtils.RewindBody(httpRequest.Content);
                Assert.AreEqual("CPASS_restapi_C0000002737000000.0002", dictBody["mocean-reqid"]);
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/verify/resend/sms"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("resend_code.json"));
            })
                );

            var mocean           = TestingUtils.GetClientObj(apiRequestMock);
            var sendCodeResponse = (SendCodeResponse)ResponseFactory.CreateObjectfromRawResponse <SendCodeResponse>(TestingUtils.ReadFile("resend_code.json"))
                                   .SetRawResponse(TestingUtils.ReadFile("resend_code.json"));

            sendCodeResponse.Client = mocean.SendCode;

            var resendCodeResponse = sendCodeResponse.Resend();

            Assert.AreEqual(resendCodeResponse.Status, "0");
            Assert.AreEqual(resendCodeResponse.ReqId, "CPASS_restapi_C0000002737000000.0002");
            Assert.AreEqual(resendCodeResponse.To, "60123456789");
            Assert.AreEqual(resendCodeResponse.ResendNumber, "1");
        }
Exemple #2
0
        public void XmlHangupTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                var dictBody = TestingUtils.RewindBody(httpRequest.Content);
                Assert.AreEqual("xxx-xxx-xxx-xxx", dictBody["mocean-call-uuid"]);
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/voice/hangup"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("hangup.xml"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);
            var res    = mocean.Voice.Hangup("xxx-xxx-xxx-xxx");

            Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("hangup.xml"));
            Assert.AreEqual(res.Status, "0");
        }