Пример #1
0
 public ValidateScan(ICheckBalance checkBalance, ICheckTerminal checkTerminal, IProcessPayment processPayment, INewCardScanned newCardScanned)
 {
     _checkTerminal  = checkTerminal;
     _checkBalance   = checkBalance;
     _processPayment = processPayment;
     _newCardScanned = newCardScanned;
 }
Пример #2
0
        public CreateFakeDatabaseContext()
        {
            string databaseName = Guid.NewGuid().ToString();

            _context = TestContextCreater.Create(databaseName);

            _context.Employees.Add(new Employee()
            {
                CardUid = "04346C824D5380",
                Balance = 10,
                Email   = "*****@*****.**"
            });

            _context.Employees.Add(new Employee()
            {
                CardUid = "99999999999999",
                Balance = 0,
                Email   = "*****@*****.**"
            });

            var terminals = new Faker <Terminal>()
                            .RuleFor(x => x.TerminalId, x => Guid.NewGuid().ToString())
                            .Generate(10);

            _context.Terminals.Add(new Terminal()
            {
                TerminalId = "04346C824D538012",
                ProductId  = 1
            });

            _context.Terminals.AddRange(terminals);

            var products = new Faker <Product>()
                           .RuleFor(x => x.ProductId, x => x.IndexFaker + 1)
                           .RuleFor(x => x.Productname, x => x.Commerce.ProductName())
                           .RuleFor(x => x.ProductDescription, x => x.Lorem.Sentence())
                           .RuleFor(x => x.ProductPrice, x => Convert.ToDecimal((x.Commerce.Price(0.5m, 2m))))
                           .RuleFor(x => x.Terminal, x => x.PickRandom(terminals))
                           .Generate(10);

            _context.Products.AddRange(products);

            var loggerFactory = new LoggerFactory();

            var getBalance = new GetBalance(_context);

            _checkBalance = new CheckBalance(getBalance, loggerFactory);

            var getProduct = new GetProduct(_context);

            _checkTerminal = new CheckTerminal(getProduct, loggerFactory);

            var writeTransaction = new WriteTransaction(_context, loggerFactory);

            _processPayment = new ProcessPayment(writeTransaction);

            var writeNewcard = new WriteNewCard(_context, loggerFactory);

            _newCardScanned = new NewCardScanned(writeNewcard, getProduct);

            _context.SaveChanges();
        }