Esempio n. 1
0
        public async Task CalculateAsync_WhenCalled_ReturnsSameCreditInfo()
        {
            ICreditInfo sut = CreateSut();

            ICreditInfo result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result, Is.SameAs(sut));
        }
Esempio n. 2
0
        public async Task CalculateAsync_WhenCalled_AssertPostingLineCollectionWasCalledOnAccount()
        {
            Mock <IAccount> accountMock = _fixture.BuildAccountMock();
            ICreditInfo     sut         = CreateSut(accountMock.Object);

            await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            accountMock.Verify(m => m.PostingLineCollection, Times.Once);
        }
Esempio n. 3
0
        public async Task CalculateAsync_WhenCalled_ReturnsSameCreditInfoWhereStatusDateEqualDateFromCall()
        {
            ICreditInfo sut = CreateSut();

            DateTime    statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            ICreditInfo result     = await sut.CalculateAsync(statusDate);

            Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date));
        }
Esempio n. 4
0
        public async Task CalculateAsync_WhenCalled_AssertBalanceIsCalculated()
        {
            DateTime today           = DateTime.Today;
            DateTime calculationDate = DateTime.Today.AddMonths(_random.Next(1, 5) * -1).AddDays(today.Day * -1).AddDays(1);

            int year  = calculationDate.Year;
            int month = calculationDate.Month;

            decimal calculatedPostingValue = _fixture.Create <decimal>();
            IPostingLineCollection postingLineCollection = _fixture.BuildPostingLineCollectionMock(calculatedPostingValue: calculatedPostingValue).Object;
            IAccount    account = _fixture.BuildAccountMock(postingLineCollection: postingLineCollection).Object;
            ICreditInfo sut     = CreateSut(account, (short)year, (short)month);

            ICreditInfo result = await sut.CalculateAsync(calculationDate);

            Assert.That(result.Balance, Is.EqualTo(calculatedPostingValue));
        }
Esempio n. 5
0
        public async Task CalculateAsync_WhenStatusDateIsNewerThanCreditInfo_AssertCalculatePostingValueWasCalledOnPostingLineCollectionFromAccount()
        {
            DateTime statusDate = DateTime.Today;

            int year  = statusDate.AddMonths(-3).Year;
            int month = statusDate.AddMonths(-3).Month;

            Mock <IPostingLineCollection> postingLineCollectionMock = _fixture.BuildPostingLineCollectionMock();
            IAccount    account = _fixture.BuildAccountMock(postingLineCollection: postingLineCollectionMock.Object).Object;
            ICreditInfo sut     = CreateSut(account, (short)year, (short)month);

            await sut.CalculateAsync(statusDate);

            postingLineCollectionMock.Verify(m => m.CalculatePostingValue(
                                                 It.Is <DateTime>(value => value == DateTime.MinValue),
                                                 It.Is <DateTime>(value => value == new DateTime(year, month, DateTime.DaysInMonth(year, month))),
                                                 It.Is <int?>(value => value.HasValue == false)),
                                             Times.Once());
        }