public Processing_Failed_At_Bank(TestFixture fixture) : base(fixture) { _request = RequestGenerator.Generate(); _request.MerchantId = "FailMerchant"; _httpResponseMessage = HttpClient.PostAsJsonAsync("/payments", _request).Result; _processPaymentResponse = DeserializeJson <ProcessPaymentResponse>(_httpResponseMessage.Content.ReadAsStringAsync().Result); }
private void GenerateTestUnit(ref RequestGenerator prg, bool expectedHasNext, string[] expectedReturn = null) { bool hasNext = prg.HasNext(); if (!expectedHasNext) { Assert.False(hasNext); return; } Assert.True(hasNext); Assert.AreEqual(expectedReturn, prg.Generate()); }
public async Task Process_Returns_Created_When_Request_Succeeds() { // Arrange var request = RequestGenerator.Generate(); Mocker.GetMock <IPaymentRepository>() .Setup(x => x.UpsertAsync(It.IsAny <Payment>())) .ReturnsAsync((Payment p) => p) .Verifiable(); // Act var actual = await SUT.PostAsJsonAsync("/payments", request); // Assert Mocker.VerifyAll(); actual.StatusCode.Should().Be(HttpStatusCode.Accepted); }
public async Task Process_Returns_InternalServerError_When_Bank_Returns_Invalid_Status() { // Arrange var request = RequestGenerator.Generate(); request.MerchantId = "EdgeCaseMerchant"; Mocker.GetMock <IPaymentRepository>() .Setup(x => x.UpsertAsync(It.IsAny <Payment>())) .ReturnsAsync((Payment p) => p) .Verifiable(); // Act var actual = await SUT.PostAsJsonAsync("/payments", request); // Assert Mocker.VerifyAll(); actual.StatusCode.Should().Be(HttpStatusCode.InternalServerError); }
public Processing_Succeeded(TestFixture fixture) : base(fixture) { _request = RequestGenerator.Generate(); _httpResponseMessage = HttpClient.PostAsJsonAsync("/payments", _request).Result; _processPaymentResponse = DeserializeJson <ProcessPaymentResponse>(_httpResponseMessage.Content.ReadAsStringAsync().Result); }