public void CanSerializeGenerateRequestMessage()
        {
            var generateRequestMessage = new GenerateRequestMessageFixture
            {

            }.Build();

            var xml = XmlMessageSerializer.Serialize(generateRequestMessage);
        }
        public void SetsTxnTypeAsExpected()
        {
            var auth = new GenerateRequestMessageFixture
            {
                TxnType = TxnType.Auth
            }.Build();

            var purchase = new GenerateRequestMessageFixture
            {
                TxnType = TxnType.Purchase
            }.Build();

            Assert.Equal(TxnType.Auth.ToString(), auth.TxnType);
            Assert.Equal(TxnType.Purchase.ToString(), purchase.TxnType);
        }
Exemple #3
0
        public async Task CallsApiToGenerateRequest() {
            var message = new GenerateRequestMessageFixture().Build();
            var response = new RequestMessageFixture().Build();
            var validator = new Mock<IDataAnnotationsValidator>();
            validator.Setup(m => m.Validate(message))
                .Returns(Enumerable.Empty<PropertyValidationResult>())
                .Verifiable();
            var api = new Mock<IPaymentExpressApi>();
            api.Setup(m => m.PostGenerateRequestAsync(message))
                .ReturnsAsync(response)
                .Verifiable();

            var payfit = new DpsPayfitFixture
            {
                Api = api.Object,
                Validator = validator.Object
            }.Build();

            var result = await payfit.CreateGenerateRequest(message);

            Assert.Equal(response, result);
            validator.VerifyAll();
            api.VerifyAll();
        }
 public async Task ConductsGenertaeRequestMessageAsExpected(HttpStatusCode statusCode)
 {
     var message = new GenerateRequestMessageFixture().Build();
     var response = new HttpResponseMessage(statusCode)
     {
         Content = new StringContent(MockResponse)
     };
     var service = new Mock<IGenerateRequest>();
     service.Setup(m => m.GenerateRequest(It.IsAny<string>())).ReturnsAsync(response).Verifiable();
     var api = new PaymentExpressApiFixture
     {
         GenerateRequestService = service.Object
     }.Build();
     if (statusCode == HttpStatusCode.OK)
     {
         var result = await api.PostGenerateRequestAsync(message);
         Assert.True(result.IsValid);
     }
     else
     {
         await Assert.ThrowsAsync<Exception>(() => api.PostGenerateRequestAsync(message));
     }
     service.VerifyAll();
 }
        public void SetsClientTypeAsExpected()
        {
            var internet = new GenerateRequestMessageFixture
            {
                ClientType = ClientType.Internet
            }.Build();

            var recurring = new GenerateRequestMessageFixture
            {
                ClientType = ClientType.Recurring
            }.Build();

            Assert.Equal(ClientType.Internet.ToString(), internet.ClientType);
            Assert.Equal(ClientType.Recurring.ToString(), recurring.ClientType);
        }
        public void SetsTimeoutValueFormatAsExpected()
        {
            var currentTime = DateTimeOffset.UtcNow;
            var withTimeout = new GenerateRequestMessageFixture
            {
                Timeout = currentTime
            }.Build();

            var withoutTimeout = new GenerateRequestMessageFixture
            {
                Timeout = null
            }.Build();

            Assert.Equal($"{currentTime:yyMMddHHmm}", withTimeout.Timeout);
            Assert.Null(withoutTimeout.Timeout);
        }