public void CreatePaymentAsync_Payment_Inserted_Returns_true()
        {
            // Arrange
            var bankUrl = "someUrl";

            var configRootMock = new Mock<IConfigurationSection>();
            configRootMock.SetupGet(m => m.Key)
                .Returns("ExternalBankUri");
            configRootMock.SetupGet(m => m.Value)
                .Returns(bankUrl);

            var configurationSections = new IConfigurationSection[1]
            {
                configRootMock.Object,
            };

            PGConfiguration.SetKeyValues(configurationSections);

            var dbContextMock = _mocks.Create<IDatabaseContext>();
            dbContextMock.Setup(m => m.Insert(It.Is<PaymentDto>(p =>
                 p.Uid == "Fake" &&
                 p.State == Framework.Enums.PaymentState.Completed)))
                .Returns(1);

            var responseMessage = new HttpResponseMessage();
            responseMessage.StatusCode = HttpStatusCode.OK;
            responseMessage.Content = new FakeHttpContent("Fake");

            var httpClientWrapperMock = _mocks.Create<IHttpClientWrapper>();
            httpClientWrapperMock.Setup(m => m.PostAsync(bankUrl, It.IsAny<StringContent>()))
                .Returns(Task.FromResult(responseMessage));
            httpClientWrapperMock.Setup(m => m.Dispose());

            var paymentBLL = new PaymentBLL(dbContextMock.Object, httpClientWrapperMock.Object);

            // Act
            var res = paymentBLL.CreatePaymentAsync(new PaymentDto()).Result;

            // Assert
            _mocks.Verify();
            Assert.AreEqual(res, true);
        }
        public void CreatePaymentAsync_Status_Code_Not_200_Returns_False()
        {
            // Arrange
            var bankUrl = "someUrl";

            var configRootMock = new Mock<IConfigurationSection>();
            configRootMock.SetupGet(m => m.Key)
                .Returns("ExternalBankUri");
            configRootMock.SetupGet(m => m.Value)
                .Returns(bankUrl);

            var configurationSections = new IConfigurationSection[1]
            {
                configRootMock.Object,
            };

            PGConfiguration.SetKeyValues(configurationSections);

            var responseMessage = new HttpResponseMessage();
            responseMessage.StatusCode = HttpStatusCode.NotFound;
            responseMessage.Content = new FakeHttpContent("Fake");

            var httpClientWrapperMock = _mocks.Create<IHttpClientWrapper>();
            httpClientWrapperMock.Setup(m => m.PostAsync(bankUrl, It.IsAny<StringContent>()))
                .Returns(Task.FromResult(responseMessage));
            httpClientWrapperMock.Setup(m => m.Dispose());

            var paymentBLL = new PaymentBLL(null, httpClientWrapperMock.Object);

            // Act
            var res = paymentBLL.CreatePaymentAsync(new PaymentDto()).Result;

            // Assert
            _mocks.Verify();
            Assert.AreEqual(res, false);
        }