public void ShouldReturnFirstDayOfMonthYear()
        {
            // Arrange
            MonthYear monthYear = MonthYear.Create(2018, 5);

            // Act
            DateTime firstDay = monthYear.GetFirstDay();

            // Assert
            Assert.Equal(DateTime.Parse("2018-05-01"), firstDay);
        }
Exemple #2
0
        public void GetCreditCardWithCurrentAndNextBills_RecoveryExistingBills()
        {
            // Arrange
            MonthYear       monthYear  = MonthYear.Create(2018, 4);
            DbCreditCardDto creditCard = testsUtils.AddSingleCreditCard();

            var bill = new DbCreditCardBillDto()
            {
                CreditCardId = creditCard.Id,
                ClosingDay   = TestsUtils.CLOSING_DAY + 1,
                DueDate      = monthYear.GetFirstDay(),
                CategoryId   = creditCard.CategoryId
            };

            dbUtils.Insert(bill);

            var statement = new DbCreditCardStatementDto()
            {
                BillId      = bill.Id,
                Amount      = 100m,
                BuyDate     = DateTime.Parse("2018-05-05"),
                Description = "test credit card statement"
            };

            dbUtils.Insert(statement);

            var sut = new CreditCardController(new CreditCardRepository(dbUtils.DbContext));

            // Act
            var creditCardList = sut.GetList(monthYear);

            // Assert
            Assert.Equal(1, creditCardList.Count);

            CreditCardBill currentBill = creditCardList.First().GetCurrentBill(monthYear);

            Assert.Equal(bill.Id, currentBill.Id);
            Assert.Equal(TestsUtils.CLOSING_DAY + 1, currentBill.ClosingDay);
            Assert.Equal(creditCard.Id, currentBill.CreditCard.Id);
            Assert.Equal(1, currentBill.Statements.Count);

            CreditCardBill nextBill = creditCardList.First().GetNextBill(monthYear);

            Assert.True(nextBill.Id > 0);
            Assert.Equal(TestsUtils.CLOSING_DAY, nextBill.ClosingDay);
            Assert.Equal(creditCard.Id, nextBill.CreditCard.Id);
            Assert.Equal(0, nextBill.Statements.Count);
        }
        public void GetFirstDayTest()
        {
            var my = new MonthYear(1, 2000);
            var actual = my.GetFirstDay();
            var expected = new DateTime(2000, 1, 1);

            Assert.AreEqual(expected, actual);
        }