Exemple #1
0
 public async Task MakeECommercePayment_Throws_Http_Exception_For_Not_Ok_Status_Codes()
 {
     var mockHttp = MockHttp.WithStatus(500);
     var client   = new SwishClient(_configuration, mockHttp);
     await Assert.ThrowsAsync <HttpRequestException>(() =>
                                                     client.MakeECommercePaymentAsync(_defaultECommercePaymentModel));
 }
Exemple #2
0
        public async Task MakeECommercePayment_Throws_Swich_Exception_When_Status_Code_Is_422()
        {
            var errorMsg  = "Testing error";
            var mockHttp  = MockHttp.WithStatusAndContent(422, errorMsg);
            var client    = new SwishClient(_configuration, mockHttp);
            var exception = await Assert.ThrowsAsync <SwishException>(() =>
                                                                      client.MakeECommercePaymentAsync(_defaultECommercePaymentModel));

            Assert.Equal(errorMsg, exception.Message);
        }
Exemple #3
0
        public async Task MakeECommercePayment_Returns_Location_Header_Values()
        {
            string paymentId      = "AB23D7406ECE4542A80152D909EF9F6B";
            string locationHeader = $"https://mss.swicpc.bankgirot.se/swishcpcapi/v1/paymentrequests/{paymentId}";
            var    headerValues   = new Dictionary <string, string>()
            {
                { "Location", locationHeader }
            };
            var responseMessage = Create201HttpJsonResponseMessage(_defaultECommercePaymentModel, headerValues);
            var client          = new SwishClient(_configuration, MockHttp.WithResponseMessage(responseMessage));

            // Act
            var response = await client.MakeECommercePaymentAsync(_defaultECommercePaymentModel);

            // Assert
            Assert.Equal(locationHeader, response.Location);
            Assert.Equal(paymentId, response.Id);
        }