Ejemplo n.º 1
0
        public void ChangeCurrency()
        {
            var ctx  = connectionPersistent;
            var user = ctx.PLATFORM_USER.FirstOrDefault(x => x.TRANSFER.Count > 0 && x.PLATFORM_USER_ACCOUNT.Count > 0);

            if (user == null)
            {
                Assert.Fail("В БД нет необходимых для теста данных");
            }

            var walletBalanceBefore  = user.WALLET.Balance;
            var walletCurrencyBefore = user.WALLET.Currency;
            var walletCurrencyNew    = ctx.SPOT.First(x => x.ComBase != walletCurrencyBefore).ComBase;

            WalletError error;
            var         wallet = walletManager.ChangeCurrency(user.ID, walletCurrencyNew, false, out error);

            Assert.AreEqual(WalletError.OK, error);

            Assert.AreNotEqual(walletCurrencyBefore, wallet.Currency);
            Assert.AreEqual(walletCurrencyNew, user.WALLET.Currency);
            Assert.AreEqual(walletCurrencyNew, wallet.Currency);

            Assert.IsTrue(walletBalanceBefore.RoughCompares(user.WALLET.Balance, 0.0001m));

            wallet = walletManager.ChangeCurrency(user.ID, walletCurrencyBefore, false, out error);
        }