public void StaticCounterTests_Battery() { const long nextIters = 1000L; StaticCounter.Reset(); Assert.That(StaticCounter.Value, Is.EqualTo(0), "counter should be 0 after Reset()"); for (var counter = 1L; counter < nextIters; ++counter) { Assert.That(StaticCounter.Next(), Is.EqualTo(counter), "Next() should return the next value in the sequence"); Assert.That(StaticCounter.Value, Is.EqualTo(counter), "Value should return current value"); } Assert.That(StaticCounter.Next(), Is.EqualTo(nextIters), "Next() should return the next value in the sequence"); Assert.That(StaticCounter.Reset(), Is.EqualTo(nextIters), "Reset() should return the value before being set to 0"); Assert.That(StaticCounter.Value, Is.EqualTo(0), "The result of Reset() should be a value of 0"); }
public async Task <Customer> Add(Customer customer) { int CustomerMainCurrencyId = customer.MainCurrencyId; var listOfCustomerAccounts = customer.Accounts; var countOfAccountsInDb = await _context.Accounts.CountAsync(); if (countOfAccountsInDb != 0) { maxOFAccountNumber = await _context.Accounts .MaxAsync(a => a.AccountNumber); } foreach (Account account in listOfCustomerAccounts) { account.BalanceWithAccountCurrency = await BalanceWithAccountCurrency(account); account.BalanceWithCustomerMainCurrency = await BalanceWithCustomerMainCurrency(CustomerMainCurrencyId, account); countOfAccountsInDb = await _context.Accounts.CountAsync(); if (countOfAccountsInDb != 0) { account.AccountNumber = maxOFAccountNumber + StaticCounter.AddOne(); } else if (StaticCounter.count >= 0 && countOfAccountsInDb == 0) { account.AccountNumber = StaticCounter.AddOne(); } } _context.Add(customer); await _context.SaveChangesAsync(); return(customer); }
public Defect() { ID = StaticCounter.Next(); }