Exemple #1
0
 public UnitOfWork(FiledPaymentDbContext dbContext,
                   IAsyncRepository <Payment> paymentRepository,
                   IAsyncRepository <PaymentState> paymentStateRepository)
 {
     _dbContext    = dbContext;
     Payments      = paymentRepository;
     PaymentStates = paymentStateRepository;
 }
        private FiledPaymentDbContext GetContextWithData()
        {
            var options = new DbContextOptionsBuilder <FiledPaymentDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new FiledPaymentDbContext(options);

            context.PaymentStates.Add(new PaymentState {
                Id = 1, Name = "Processed"
            });

            return(context);
        }
        public PaymentServiceShould()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AllowNullCollections = true;
                cfg.AddProfile <PaymentMappingProfile>();
            });

            _mapper                      = config.CreateMapper();
            _dbContext                   = GetContextWithData();
            _paymentRepository           = new BaseRepository <Payment>(_dbContext);
            _paymentStateRepository      = new BaseRepository <PaymentState>(_dbContext);
            _unitOfWork                  = new UnitOfWork(_dbContext, _paymentRepository, _paymentStateRepository);
            _mockExpensivePaymentGateway = new Mock <IExpensivePaymentGateway>();
            _mockCheapPaymentGateway     = new Mock <ICheapPaymentGateway>();
            _paymentService              = new PaymentService(_mapper, _unitOfWork, _mockExpensivePaymentGateway.Object, _mockCheapPaymentGateway.Object);
        }
Exemple #4
0
 public BaseRepository(FiledPaymentDbContext dbContext)
 {
     _dbContext = dbContext;
 }