public void ShouldReturnTrueForExistingEmail() { string emailToBeChecked = "*****@*****.**"; using (var context = new AmfMoneyContext(_options)) { AccountEntity account = new AccountEntity() { Birth = new DateTime(1991, 03, 15), Email = emailToBeChecked, HashedPassword = new byte[] { 1, 2 }, HashedPin = new byte[] { 1, 2 }, PasswordSalt = new byte[] { 1, 2 }, PinSalt = new byte[] { 1, 2 } }; context.Accounts.Add(account); context.SaveChanges(); } var accountService = new AccountService(new AmfMoneyContext(_options)); bool actual = accountService.CheckIfExists(emailToBeChecked); Assert.True(actual); }
public void ShouldUpdate() { using (var context = new AmfMoneyContext(_options)) { context.Add(new Trade() { OperationType = 'B' }); context.SaveChanges(); } using (var context = new AmfMoneyContext(_options)) { var service = new TradeService(context); var trade = context.Find <Trade>(1); trade.OperationType = 'S'; service.Update(trade); } using (var context = new AmfMoneyContext(_options)) { var trade = context.Find <Trade>(1); Assert.Equal('S', trade.OperationType); } }
public void ShouldCreateNew() { AccountEntity account = GenerateAccount(); using (var context = new AmfMoneyContext(_options)) { context.Accounts.Add(account); context.SaveChanges(); } using (var tradingBookService = new TradingBookService(new AmfMoneyContext(_options))) { TradingBookSetting setting = GenerateSetting(); TradingBookEntity actual = tradingBookService.Create(account.Id, setting); Assert.True(actual.Id > 0); Assert.Equal(setting, actual.Setting); Assert.NotEqual(default, actual.CreatedAt);
public void ShouldReturnFalseForNonExistingEmail() { using (var context = new AmfMoneyContext(_options)) { AccountEntity user = new AccountEntity() { Birth = new DateTime(1991, 03, 15), Email = "*****@*****.**", HashedPassword = new byte[] { 1, 2 }, HashedPin = new byte[] { 1, 2 }, PasswordSalt = new byte[] { 1, 2 }, PinSalt = new byte[] { 1, 2 } }; context.Accounts.Add(user); context.SaveChanges(); } var accountService = new AccountService(new AmfMoneyContext(_options)); bool actual = accountService.CheckIfExists("*****@*****.**"); Assert.False(actual); }
public void ShouldSignUp() { int expectedId; using (var accountService = new AccountService(new AmfMoneyContext(_options))) { Account account = new Account() { Birth = new DateTime(1991, 03, 15), Email = "*****@*****.**", Password = "******", Pin = "1234" }; expectedId = accountService.SignUp(account); } using (var context = new AmfMoneyContext(_options)) { AccountEntity expected = context.Accounts.Find(expectedId); Assert.NotNull(expected); } }
public TradingBookService(AmfMoneyContext context) { _context = context; }
protected Service(AmfMoneyContext context) { _context = context; }
public TradeService(AmfMoneyContext context) { _context = context; }
public TradingBookService(AmfMoneyContext context) : base(context) { }
public AccountService(AmfMoneyContext context) : base(context) { }