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)); }
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); }
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)); }
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)); }
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()); }