public async Task GetPreparationAsync_throws_IamportResponseException_when_response_code_is_not_success() { // arrange var expectedRequest = Guid.NewGuid().ToString(); var expectedResult = new IamportResponse <PaymentPreparation> { Code = -1, HttpStatusCode = HttpStatusCode.InternalServerError, }; var client = GetMockClient(expectedResult); var sut = new PaymentsApi(client); // act/assert await Assert.ThrowsAsync <IamportResponseException>( () => sut.GetPreparationAsync(expectedRequest)); }
public async Task GetPreparationAsync_requests_proper_uri() { // arrange var expectedRequest = Guid.NewGuid().ToString(); var expectedResult = new IamportResponse <PaymentPreparation> { HttpStatusCode = HttpStatusCode.OK, }; var expectedPath = $"payments/prepare/{expectedRequest}"; var client = GetMockClient(expectedResult); var sut = new PaymentsApi(client); // act var result = await sut.GetPreparationAsync(expectedRequest); // assert Mock.Get(client) .Verify(mocked => mocked.RequestAsync <object, PaymentPreparation>( It.Is <IamportRequest>(req => req.ApiPathAndQueryString.EndsWith(expectedPath)))); }
public async Task GetPreparationAsync_GuardClause(string id) { var sut = new PaymentsApi(GetEmptyMockClient()); await Assert.ThrowsAsync <ArgumentNullException>( () => sut.GetPreparationAsync(id)); }