public async Task CalculateAsync_WhenCalled_ReturnsSameBudgetInfo() { IBudgetInfo sut = CreateSut(); IBudgetInfo result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); Assert.That(result, Is.SameAs(sut)); }
public async Task CalculateAsync_WhenCalled_AssertPostingLineCollectionWasCalledOnBudgetAccount() { Mock <IBudgetAccount> budgetAccountMock = _fixture.BuildBudgetAccountMock(); IBudgetInfo sut = CreateSut(budgetAccountMock.Object); await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); budgetAccountMock.Verify(m => m.PostingLineCollection, Times.Once); }
public async Task CalculateAsync_WhenCalled_ReturnsSameBudgetInfoWhereStatusDateEqualDateFromCall() { IBudgetInfo sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IBudgetInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date)); }
public async Task CalculateAsync_WhenCalled_AssertPostedIsCalculated() { 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; IBudgetAccount budgetAccount = _fixture.BuildBudgetAccountMock(postingLineCollection: postingLineCollection).Object; IBudgetInfo sut = CreateSut(budgetAccount, (short)year, (short)month); IBudgetInfo result = await sut.CalculateAsync(calculationDate); Assert.That(result.Posted, Is.EqualTo(calculatedPostingValue)); }
public async Task CalculateAsync_WhenStatusDateIsNewerThanBudgetInfo_AssertCalculatePostingValueWasCalledOnPostingLineCollectionFromBudgetAccount() { DateTime statusDate = DateTime.Today; int year = statusDate.AddMonths(-3).Year; int month = statusDate.AddMonths(-3).Month; Mock <IPostingLineCollection> postingLineCollectionMock = _fixture.BuildPostingLineCollectionMock(); IBudgetAccount budgetAccount = _fixture.BuildBudgetAccountMock(postingLineCollection: postingLineCollectionMock.Object).Object; IBudgetInfo sut = CreateSut(budgetAccount, (short)year, (short)month); await sut.CalculateAsync(statusDate); postingLineCollectionMock.Verify(m => m.CalculatePostingValue( It.Is <DateTime>(value => value == new DateTime(year, month, 1)), It.Is <DateTime>(value => value == new DateTime(year, month, DateTime.DaysInMonth(year, month))), It.Is <int?>(value => value.HasValue == false)), Times.Once()); }