Ejemplo n.º 1
0
        public async Task SetUp()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();

            var services = new ServiceCollection();

            services.AddTransient <IReflinkHelper, ReflinkHelper>();
            services.AddTransient <IUserAccountDataHelper, UserAccountDataHelper>();
            services.AddTransient <IMatrixPositionHelper, MatrixPositionHelper>();
            services.AddTransient <IUserMultiAccountHelper, UserMultiAccountHelper>();
            services.AddTransient <IPaymentHistoryHelper, PaymentHistoryHelper>();
            services.AddTransient <IUserAccountDataRepository, UserAccountDataRepository>();
            services.AddTransient <IUserMultiAccountRepository, UserMultiAccountRepository>();
            services.AddTransient <IMatrixPositionRepository, MatrixPositionRepository>();
            services.AddTransient <IPaymentHistoryRepository, PaymentHistoryRepository>();
            services.AddTransient <IArticleRepository, ArticleRepository>();
            services.AddTransient <ITicketRepository, TicketRepository>();
            services.AddTransient <IWithdrawalRepository, WithdrawalRepository>();
            services.Configure <JwtSettings>(configuration.GetSection("JwtSettings"));

            services.AddAutoMapper();
            services.AddMediatR(typeof(RegisterNewUserAccountCommand).Assembly);

            var connectionString = $@"Server=XARDASLORD\SQLEXPRESS;Database=BitClub7_integration_tests_{Guid.NewGuid()};Integrated Security=SSPI";

            services.AddDbContext <IBitClub7Context, BitClub7Context>(
                opts => opts.UseSqlServer(connectionString,
                                          b => b.MigrationsAssembly(typeof(IBitClub7Context).Namespace))
                );

            var serviceProvider = services.AddEntityFrameworkSqlServer()
                                  .BuildServiceProvider();

            _context                    = serviceProvider.GetRequiredService <IBitClub7Context>();
            _mapper                     = serviceProvider.GetRequiredService <IMapper>();
            _mediator                   = serviceProvider.GetRequiredService <IMediator>();
            _reflinkHelper              = serviceProvider.GetRequiredService <IReflinkHelper>();
            _userAccountDataHelper      = serviceProvider.GetRequiredService <IUserAccountDataHelper>();
            _matrixPositionHelper       = serviceProvider.GetRequiredService <IMatrixPositionHelper>();
            _userMultiAccountHelper     = serviceProvider.GetRequiredService <IUserMultiAccountHelper>();
            _paymentHistoryHelper       = serviceProvider.GetRequiredService <IPaymentHistoryHelper>();
            _userAccountDataRepository  = serviceProvider.GetRequiredService <IUserAccountDataRepository>();
            _userMultiAccountRepository = serviceProvider.GetRequiredService <IUserMultiAccountRepository>();
            _matrixPositionRepository   = serviceProvider.GetRequiredService <IMatrixPositionRepository>();
            _paymentHistoryRepository   = serviceProvider.GetRequiredService <IPaymentHistoryRepository>();
            _articleRepository          = serviceProvider.GetRequiredService <IArticleRepository>();
            _ticketRepository           = serviceProvider.GetRequiredService <ITicketRepository>();
            _withdrawalRepository       = serviceProvider.GetRequiredService <IWithdrawalRepository>();
            _jwtSettings                = serviceProvider.GetRequiredService <IOptions <JwtSettings> >();
            _bitBayPayApiSettings       = serviceProvider.GetRequiredService <IOptions <BitBayPayApiSettings> >();
            _matrixStructureSettings    = serviceProvider.GetRequiredService <IOptions <MatrixStructureSettings> >();
            _storageSettings            = serviceProvider.GetRequiredService <IOptions <StorageSettings> >();

            _context.Database.Migrate();
            await ClearDatabase();
        }
 public UserBoughtMatrixPositionJob(IUserMultiAccountRepository userMultiAccountRepository, IReflinkHelper reflinkHelper)
 {
     _userMultiAccountRepository = userMultiAccountRepository;
     _reflinkHelper = reflinkHelper;
 }