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"); }
public void RequiredFieldNotSetTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { return(TestingUtils.GetResponse("number_lookup.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); Assert.Throws <RequiredFieldException>(() => { mocean.NumberLookup.Inquiry(new NumberLookupRequest()); }); }
public void RequiredFieldNotSetTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { return(TestingUtils.GetResponse("message.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); Assert.Throws <RequiredFieldException>(() => { mocean.Sms.Send(new SmsRequest()); }); }
public void XmlSendTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/sms", "1"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("message.xml")); }) ); apiRequestMock.ApiRequestConfig.Version = "1"; var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Sms.Send(new SmsRequest { mocean_from = "testing from", mocean_text = "testing text", mocean_to = "testing to", mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message.xml")); TestObject(res); //V2 Test apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/sms"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("message_v2.xml")); }) ); apiRequestMock.ApiRequestConfig.Version = "2"; mocean = TestingUtils.GetClientObj(apiRequestMock); res = mocean.Sms.Send(new SmsRequest { mocean_from = "testing from", mocean_text = "testing text", mocean_to = "testing to", mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message_v2.xml")); TestObject(res); }
public void JsonInquiryTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/account/pricing"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("price.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Pricing.Inquiry(); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("price.json")); TestObject(res); }
public void RecordingErrorTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/voice/rec"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("error_response.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); Assert.Throws <MoceanErrorException>(() => { mocean.Voice.Recording("xxx-xxx-xxx-xxx"); }); }
public void ResendTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { 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); mocean.SendCode.Resend(new SendCodeRequest { mocean_reqid = "test req id" }); }
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"); }
public void RecordingCallTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/voice/rec"), httpRequest.RequestUri.LocalPath); var mockResponse = TestingUtils.GetResponse("recording.json"); mockResponse.Content.Headers.ContentType = new MediaTypeHeaderValue("audio/mpeg"); return(mockResponse); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Voice.Recording("xxx-xxx-xxx-xxx"); Assert.IsNotNull(res.RecordingBuffer); Assert.AreEqual(res.Filename, "xxx-xxx-xxx-xxx.mp3"); }
public void JsonInquiryTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/nl"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("number_lookup.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.NumberLookup.Inquiry(new NumberLookupRequest { mocean_to = "testing to" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("number_lookup.json")); TestObject(res); }
public void JsonCallTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/voice/dial"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("voice.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Voice.Call(new VoiceRequest { mocean_to = "testing to" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("voice.json")); TestObject(res); }
public void JsonInquiryTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/report/message"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("message_status.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.MessageStatus.Inquiry(new MessageStatusRequest { mocean_msgid = "test msg id" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message_status.json")); TestObject(res); }
public void XmlInquiryTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/account/balance"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("balance.xml")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Balance.Inquiry(new BalanceRequest { mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("balance.xml")); TestObject(res); }
public void JsonSendTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/verify/check"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("verify_code.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.VerifyCode.Send(new VerifyCodeRequest { mocean_code = "testing code", mocean_reqid = "testing reqid" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("verify_code.json")); TestObject(res); }
public void XmlInquiryTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/account/pricing", "1"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("price.xml")); }) ); apiRequestMock.ApiRequestConfig.Version = "1"; var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Pricing.Inquiry(new PricingRequest { mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("price.xml")); TestObject(res); //V2 Test apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Get, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/account/pricing"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("price_v2.xml")); }) ); apiRequestMock.ApiRequestConfig.Version = "2"; mocean = TestingUtils.GetClientObj(apiRequestMock); res = mocean.Pricing.Inquiry(new PricingRequest { mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("price_v2.xml")); TestObject(res); }
public void XmlSendTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/verify/req"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("send_code.xml")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.SendCode.Send(new SendCodeRequest { mocean_to = "testing to", mocean_brand = "testing brand", mocean_resp_format = "xml" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("send_code.xml")); TestObject(res); }
public void JsonSendTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/sms"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("message.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var res = mocean.Sms.Send(new SmsRequest { mocean_from = "testing from", mocean_text = "testing text", mocean_to = "testing to" }); Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message.json")); TestObject(res); }
public void SendCodeAsSmsTest() { var apiRequestMock = new ApiRequest( TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) => { Assert.AreEqual(HttpMethod.Post, httpRequest.Method); Assert.AreEqual(TestingUtils.GetTestUri("/verify/req/sms"), httpRequest.RequestUri.LocalPath); return(TestingUtils.GetResponse("send_code.json")); }) ); var mocean = TestingUtils.GetClientObj(apiRequestMock); var sendCode = mocean.SendCode; Assert.AreEqual(Channel.Auto, sendCode.Channel); sendCode.SendAs(Channel.Sms); Assert.AreEqual(Channel.Sms, sendCode.Channel); sendCode.Send(new SendCodeRequest { mocean_to = "testing to", mocean_brand = "testing brand" }); }