public void EnrolRequest_AppliesTerminalIdDefault() { var config = CreateZipConfig(); var request = new EnrolRequest(); request.ApplyDefaults(config); Assert.AreEqual(config.DefaultTerminalId, request.Terminal); }
public async Task Enrol_Handles_SuccessfulResponse() { #region Setup Mocked Client var responseHistory = new Dictionary <string, CreateOrderResponse>(); var handler = new MockHttpHandler(); handler.AddMock ( HttpMethod.Post, "https://api-ci.partpay.co.nz/pos/terminal/enrol", (httpRequest) => { return(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent ( System.Text.Json.JsonSerializer.Serialize ( new { client_id = "3D888947-1CA3-428B-A428-F53532FB8593", client_secret = "6FFD61D3-76CA-4059-8AE2-C246B52FF452" }, _SerialiserOptions ), System.Text.UTF8Encoding.UTF8, "application/json" ) })); } ); var httpClient = new HttpClient(handler); #endregion using (var client = CreateTestClient(httpClient)) { var request = new EnrolRequest() { ActivationCode = "ABC123", Secret = "zipme!", Terminal = "2531" }; var result = await client.EnrolAsync(request); Assert.IsNotNull(result); Assert.AreEqual("3D888947-1CA3-428B-A428-F53532FB8593", result.ClientId); Assert.AreEqual("6FFD61D3-76CA-4059-8AE2-C246B52FF452", result.ClientSecret); } }
public async Task ZipClient_EnrolTest() { using (var client = CreateTestClient()) { var enrolRequest = new EnrolRequest() { ActivationCode = "ABC", Secret = "123", Terminal = "2531" }; var enrolResponse = await client.EnrolAsync(enrolRequest); Assert.IsNotNull(enrolResponse); } }
public async Task ZipClient_Enrol_ThrowsZipApiExceptionOnErrorResponse() { using (var client = CreateTestClient()) { var enrolRequest = new EnrolRequest() { ActivationCode = "ABC", Secret = "123", Terminal = "2531" }; await Assert.ThrowsExceptionAsync <ZipApiException> ( async() => { await client.EnrolAsync(enrolRequest); } ); } }
public void Validate_EnrolRequest_RequiresTerminal() { var request = new EnrolRequest() { ActivationCode = "ABC", Secret = "123", Terminal = null }; Assert.ThrowsException <ArgumentNullException>(() => request.Validate()); request.Terminal = String.Empty; Assert.ThrowsException <ArgumentException>(() => request.Validate()); request.Terminal = " "; Assert.ThrowsException <ArgumentException>(() => request.Validate()); }
public void EnrolRequest_IgnoresNullZipConfig() { var request = new EnrolRequest(); request.ApplyDefaults(null); }