// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CPGContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } context.SeedData(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("./swagger/v1/swagger.json", "My Checkout Payment Gateway API"); c.RoutePrefix = string.Empty; }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
private PaymentHistoryController GetPaymentHistoryController() { _connectionFactory = new ConnectionFactory(); _context = _connectionFactory.CreateContextForSQLite(); var paymentHistory = new PaymentHistory(_context); SeedPaymentHistoryData(); return(new PaymentHistoryController(paymentHistory)); }
public void return_masked_card_number_and_statuc_payment_response() { _connectionFactory = new ConnectionFactory(); _context = _connectionFactory.CreateContextForSQLite(); var paymentHistory = new PaymentHistory(_context); SeedPaymentHistoryData(); var response = paymentHistory.GetPaymentRequest(1, 1); EndConnection(); Assert.IsTrue("************ryT1" == response.card_number); Assert.IsTrue(response.Status == "Success"); }
private ProcessPaymentRequestApiController GetProcessPaymentRequestController(bool bankReponse, PaymentRequest paymentRequest) { _connectionFactory = new ConnectionFactory(); _context = _connectionFactory.CreateContextForSQLite(); var bankMoq = new Mock <IBankService>(); var id = Guid.NewGuid(); bankMoq.Setup(x => x.GetBankPaymentResponse(paymentRequest)).Returns(new BankPaymentResponse(id, bankReponse) { PaymentRequest = paymentRequest }); var processPaymentRequest = new ProcessPaymentRequest(_context, bankMoq.Object); return(new ProcessPaymentRequestApiController(processPaymentRequest)); }
private bool disposedValue = false; // To detect redundant calls public CPGContext CreateContextForSQLite() { connection = new SqliteConnection("DataSource=:CheckoutDBTest:"); connection.Open(); var option = new DbContextOptionsBuilder <CPGContext>().UseSqlite(connection).Options; var context = new CPGContext(option); if (context != null) { // context.Database.EnsureDeleted(); context.Database.EnsureCreated(); seedDataToInMemoryDB(context); } return(context); }
public void seedDataToInMemoryDB(CPGContext context) { List <Merchant> Merchants = new List <Merchant>() { new Merchant("Merchant 1") { MinAmount = 0, MaxAmount = 1000 }, new Merchant("Merchant 2") { MinAmount = 200, MaxAmount = 2000 }, new Merchant("Merchant 3") { MinAmount = 3000, MaxAmount = 30000 } }; context.Merchants.AddRange(Merchants); context.SaveChanges(); }
public PaymentHistory(CPGContext cPGContext) { _CPGContext = cPGContext; }
public ProcessPaymentRequest(CPGContext cPGContext, IBankService bankService) { _cPGContext = cPGContext; _bankService = bankService; }