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);
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        public TradingBook Create(TradingBook toBeCreated)
        {
            TradingBook toBeAdded;

            _context.TradingBooks.Add
            (
                toBeAdded = new TradingBook()
            {
                Name            = toBeCreated.Name,
                AmountPerCaptal = toBeCreated.AmountPerCaptal / 100,
                RiskRewardRatio = toBeCreated.RiskRewardRatio,
                CreatedAt       = DateTime.UtcNow,
                RiskPerTrade    = toBeCreated.RiskPerTrade / 100,
                TotalCaptal     = toBeCreated.TotalCaptal,
                Trades          = toBeCreated.Trades
            }
            );

            _context.SaveChanges();
            return(toBeAdded);
        }
        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);
        }
Beispiel #6
0
 public void Update(Trade trade)
 {
     _context.Update(trade);
     _context.SaveChanges();
 }