Beispiel #1
0
        public void ReturnTodaysDate()
        {
            var expected     = DateTime.Now.ToString("d");
            var dateProvider = new DateProvider();

            var date = dateProvider.Now();

            Assert.That(date, Is.EqualTo(expected));
        }
    public void Now_ShouldReturnValidDate()
    {
        // Arrange
        IDateProvider dateProvider = new DateProvider();

        // Act
        DateTime now = dateProvider.Now();

        // Assert
        DateTime parsed = DateTime.Parse($"{now}");

        Assert.False(parsed == default);
    }
Beispiel #3
0
        public void Accounts_AreInterestsAccruing()
        {
            IInterestAccount _SavingsAccount;
            IInterestAccount _CheckingAccount;
            IInterestAccount _MaxiSavingsAccount;

            // Initial deposit of $100
            // Do not override the default rates
            // Compound type is daily
            _SavingsAccount     = new SavingsAccount(1000);
            _CheckingAccount    = new CheckingAccount(1000);
            _MaxiSavingsAccount = new MaxiSavingsAccount(1000);

            _SavingsAccount.Deposit(2000);                    //Tr 2
            _SavingsAccount.Withdraw(1500);                   // Tr 3
            _SavingsAccount.Deposit(10000);                   // Tr 4
            _SavingsAccount.Transfer(_CheckingAccount, 4000); // Tr 5

            DateTime _futDate_4 = DateProvider.Now().AddDays(4);
            DateTime _futDate_7 = DateProvider.Now().AddDays(7);


            // No transactions prior to the periods
            decimal _fut4_interest;
            decimal _fut7_interest;

            _fut4_interest = _SavingsAccount.InterestEarned(_futDate_4);
            _fut7_interest = _SavingsAccount.InterestEarned(_futDate_7);


            Debug.Print(_fut4_interest.ToString());

            Assert.AreEqual("$0.16", _fut4_interest.ToDollars());
            Assert.AreEqual("$0.29", _fut7_interest.ToDollars());

            // Test again when there is transaction in duration


            DateTime _futDate_8  = DateProvider.Now().AddDays(8);
            DateTime _futDate_9  = DateProvider.Now().AddDays(9);
            DateTime _futDate_11 = DateProvider.Now().AddDays(11);

            _SavingsAccount.Deposit(5000, _futDate_8);
            _SavingsAccount.Withdraw(7000, _futDate_9);

            _fut7_interest = _SavingsAccount.InterestEarned(_futDate_11);
            Assert.AreEqual("$0.46", _fut7_interest.ToDollars());
        }