public async Task Then_If_Error_Creating_A_HttpRequestContentException_Is_Thrown( CreateSubscriptionKeyCommand command, [Frozen] Mock<IApimDeveloperApiClient<ApimDeveloperApiConfiguration>> client, CreateSubscriptionKeyCommandHandler handler) { var createResponse = new ApiResponse<object>("", HttpStatusCode.BadRequest, "error"); client.Setup( x => x.PostWithResponseCode<object>(It.Is<PostCreateSubscriptionKeyRequest>(c => ((CreateSubscriptionApiRequest)c.Data).AccountIdentifier.Equals(command.AccountIdentifier) && ((CreateSubscriptionApiRequest)c.Data).ProductId.Equals(command.ProductId)))).ReturnsAsync(createResponse); Assert.ThrowsAsync<HttpRequestContentException>(() => handler.Handle(command, CancellationToken.None)); }
public async Task Then_The_Request_Is_Sent_To_Create_The_Key_And_Product_Returned( CreateSubscriptionKeyCommand command, [Frozen] Mock<IApimDeveloperApiClient<ApimDeveloperApiConfiguration>> client, CreateSubscriptionKeyCommandHandler handler) { var createResponse = new ApiResponse<object>("", HttpStatusCode.Created, ""); client.Setup( x => x.PostWithResponseCode<object>(It.Is<PostCreateSubscriptionKeyRequest>(c => ((CreateSubscriptionApiRequest)c.Data).AccountIdentifier.Equals(command.AccountIdentifier) && ((CreateSubscriptionApiRequest)c.Data).ProductId.Equals(command.ProductId)))).ReturnsAsync(createResponse); await handler.Handle(command, CancellationToken.None); client.Verify( x => x.PostWithResponseCode<object>(It.Is<PostCreateSubscriptionKeyRequest>(c => ((CreateSubscriptionApiRequest)c.Data).AccountIdentifier.Equals(command.AccountIdentifier) && ((CreateSubscriptionApiRequest)c.Data).ProductId.Equals(command.ProductId))), Times.Once); }