コード例 #1
0
        public void PositiveTestCloseAccount()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 0, 500M);
            var result  = account.CloseAccount();

            Assert.AreEqual(true, result);
        }
コード例 #2
0
        public void NegativeTestAddFunds()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Aurum, 0, 1500M);

            try
            {
                account.AddFunds(-50M);

                Assert.Fail();
            }
            catch (InvalidOperationException)  { }

            try
            {
                account.AddFunds(1000M);

                Assert.Fail();
            }
            catch (InvalidOperationException) { }

            account.CloseAccount();
            var result2 = account.AddFunds(1500M);

            Assert.AreEqual(false, result2);
            Assert.AreEqual(0M, account.AccountBalance);
            Assert.AreEqual(0L, account.MetalBalance);
        }
コード例 #3
0
        public void MiddleSumWithdrawalsBigSumMetalAccount()
        {
            MetalAccount account = new MetalAccount(Guid.NewGuid(), 10000000000000, "золото", 100);

            account.Withdrawals(1);

            Assert.AreEqual(9999999999999, account.SumAccount);
            Assert.AreEqual(99999999999.99, account.AmountGrams);
        }
コード例 #4
0
        public void MiddleSumRefillBigSumMetalAccount()
        {
            MetalAccount account = new MetalAccount(Guid.NewGuid(), 10000000000000, "золото", 100);

            account.Refill(1000);

            Assert.AreEqual(10000000001000, account.SumAccount);
            Assert.AreEqual(100000000010, account.AmountGrams);
        }
コード例 #5
0
        public void EditTypeMetalWhitNullValue()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, false, 10.00, "Uran", 100);

            const string expectedExceptionMessage = "Значение не может быть неопределенным.\r\nИмя параметра: Переданое значение NULL";

            var factException = Assert.Throws <ArgumentNullException>(() => testAccount.EditTypeMetal(null));

            Assert.That(factException.Message, Is.EqualTo(expectedExceptionMessage));
        }
コード例 #6
0
        public void EditCourseExchangeMetalWhitHugeIncorrectValue()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, false, 10.00, "Uran", 100);

            const string expectedExceptionMessage = "Заданный аргумент находится вне диапазона допустимых значений.\r\nИмя параметра: Невозможно изменить курс обмена. Курс не может превышать 100000 ведь!";

            var factException = Assert.Throws <ArgumentOutOfRangeException>(() => testAccount.EditCourseExchangeMetal(110000));

            Assert.That(factException.Message, Is.EqualTo(expectedExceptionMessage));
        }
コード例 #7
0
        public void PositiveTestAddFundsInMetal()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 0, 500M);
            var result1 = account.AddFundsInMetal(100);
            var result2 = account.AddFundsInMetal(0);

            Assert.AreEqual(true, result1);
            Assert.AreEqual(true, result2);
            Assert.AreEqual(50000M, account.AccountBalance);
            Assert.AreEqual(100, account.MetalBalance);
        }
コード例 #8
0
        public void EditTypeMetalWhithMinValue()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, false, 10.00, "Uran", 100);

            testAccount.EditTypeMetal("GOLD");

            const string expectedTypeMetal = "GOLD";

            Assert.IsTrue(testAccount.TypeMetal == expectedTypeMetal,
                          $"Фактический тип металла {testAccount.TypeMetal} отличается от ожидаемого {expectedTypeMetal}");
        }
コード例 #9
0
        public void PositiveTestZeroingAccount()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 100, 500M);
            var result1 = account.ZeroingAccount();
            var result2 = account.ZeroingAccount();

            Assert.AreEqual(true, result1);
            Assert.AreEqual(true, result2);
            Assert.AreEqual(0M, account.AccountBalance);
            Assert.AreEqual(0L, account.MetalBalance);
        }
コード例 #10
0
        public void NegativeTestZeroingAccount()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 0, 500M);

            account.CloseAccount();
            var result = account.ZeroingAccount();

            Assert.AreEqual(false, result);
            Assert.AreEqual(0M, account.AccountBalance);
            Assert.AreEqual(0L, account.MetalBalance);
        }
コード例 #11
0
        public void TestConstructor()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 100, 1500.00M);

            Assert.AreEqual("acc1", account.AccountNumber);
            Assert.AreEqual("client1", account.AccountOwner);
            Assert.AreEqual(150000.00M, account.AccountBalance);
            Assert.AreEqual(AccountStatus.Opened, account.Status);
            Assert.AreEqual(MetalType.Argentum, account.Metal);
            Assert.AreEqual((uint)100, account.MetalBalance);
            Assert.AreEqual(1500.00M, account.PriceRate);
        }
コード例 #12
0
        public void EditCourseExchangeMetalOnClosedAccount()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, true, 10.00, "Uran", 100);

            string expectedExceptionMessage =
                $"Счет {testAccount.Id} закрыт, операция не может быть произведена.";

            var factException =
                Assert.Throws <InvalidOperationException>(() => testAccount.EditCourseExchangeMetal(50));

            Assert.That(factException.Message, Is.EqualTo(expectedExceptionMessage));
        }
コード例 #13
0
        public void NegativeTestAddFundsInMetal()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Aurum, 0, 1500M);

            account.CloseAccount();

            var result = account.AddFundsInMetal(50);

            Assert.AreEqual(false, result);
            Assert.AreEqual(0M, account.AccountBalance);
            Assert.AreEqual(0L, account.MetalBalance);
        }
コード例 #14
0
        public void NegativeTestCloseAccount()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 100, 500M);
            var result1 = account.CloseAccount();

            account.ZeroingAccount();
            account.CloseAccount();
            var result2 = account.CloseAccount();

            Assert.AreEqual(false, result1);
            Assert.AreEqual(false, result2);
        }
コード例 #15
0
        public void AddFoundsToMetalAccount()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, false, 10.00, "Uran", 100);

            testAccount.AddFunds(9999900);

            const double expectedSum    = 10000900;
            const double expectedGramms = 100009;

            Assert.IsTrue(Math.Abs(testAccount.Sum - expectedSum) <= 1e-10, $"Фактическая сумма на счете {testAccount.Sum} отличается от ожидаемой {expectedSum}");

            Assert.IsTrue(Math.Abs(testAccount.GrammsMetal - expectedGramms) <= 1e-7, $"Фактическое количество грамм на счете {testAccount.GrammsMetal} отличается от ожидаемого {expectedGramms}");
        }
コード例 #16
0
        public void PositiveTestWithdrawFunds()
        {
            var account = new MetalAccount("acc1", "client1", MetalType.Platinum, 0, 2500M);

            account.AddFunds(5000M);
            var result1 = account.WithdrawFunds(2500M);
            var result2 = account.WithdrawFunds(0);

            Assert.AreEqual(true, result1);
            Assert.AreEqual(true, result2);
            Assert.AreEqual(2500M, account.AccountBalance);
            Assert.AreEqual(1L, account.MetalBalance);
        }
コード例 #17
0
        public void EditCourseExchangeMetalWhithMaxValue()
        {
            MetalAccount testAccount = new MetalAccount(2, "Test2", 00.00, false, 10.00, "Uran", 100);

            testAccount.EditCourseExchangeMetal(10000.00);

            const double expectedCourseExchangeMeta = 10000.00;
            const double expectedSum = 100000;

            Assert.IsTrue(Math.Abs(testAccount.CourseExchangeMetal - expectedCourseExchangeMeta) <= 1e-7,
                          $"Фактический курс обмена {testAccount.CourseExchangeMetal} отличается от ожидаемого {expectedCourseExchangeMeta}");

            Assert.IsTrue(Math.Abs(testAccount.Sum - expectedSum) <= 1e-10, $"Фактическая сумма на счете {testAccount.Sum} отличается от ожидаемой {expectedSum}");
        }
コード例 #18
0
ファイル: BaseClient.cs プロジェクト: yana-logical/ya.petrova
        public bool CreateMetalAccount()
        {
            MetalAccount metalAccount = new MetalAccount();

            return(AddAccount(metalAccount));
        }
コード例 #19
0
 public void NegativeTestConstructor()
 {
     var account = new MetalAccount("acc1", "client1", MetalType.Argentum, 0, 0.00M);
 }