public async Task CalculateAsync_WhenCalled_ReturnsSameInfo() { IInfo <IInfo> sut = CreateSut(); IInfo result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); Assert.That(result, Is.SameAs(sut)); }
public async Task CalculateAsync_WhenCalled_AssertAlreadyCalculatedWasNotCalledOnSut() { IInfo <IInfo> sut = CreateSut(); Sut result = (Sut)await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); Assert.That(result.AlreadyCalculatedWasCalled, Is.False); }
public async Task CalculateAsync_WhenCalled_ReturnsSameInfoWhereStatusDateEqualDateFromCall() { IInfo <IInfo> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date)); }
public async Task CalculateAsync_WhenCalled_AssertCalculateWasCalledWithSameStatusDate() { IInfo <IInfo> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); Sut result = (Sut)await sut.CalculateAsync(statusDate); Assert.That(result.CalculateCalledWithStatusDate, Is.EqualTo(statusDate.Date)); }
public async Task IsYearToDateOfStatusDate_WhenStatusDateIsWithinInfo_ReturnsTrue(short month) { short year = (short)_random.Next(Sut.MinYear, Sut.MaxYear); IInfo <IInfo> sut = CreateSut(year, month); DateTime statusDate = new DateTime(year, month, _random.Next(1, DateTime.DaysInMonth(year, month))); IInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.IsYearToDateOfStatusDate, Is.True); }
public async Task IsLastMonthOfStatusDate_WhenStatusDateIsWithinNextMonthOfInfo_ReturnsTrue(short month) { short year = (short)_random.Next(Sut.MinYear, Sut.MaxYear - 1); IInfo <IInfo> sut = CreateSut(year, month); DateTime statusDate = sut.ToDate.AddDays(_random.Next(1, DateTime.DaysInMonth(sut.ToDate.AddDays(1).Year, sut.ToDate.AddDays(1).Month))); IInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.IsLastMonthOfStatusDate, Is.True); }
public async Task IsYearToDateOfStatusDate_WhenStatusDateIsDifferentMonthAfterInfo_ReturnsTrue(short month) { short year = (short)_random.Next(Sut.MinYear, Sut.MaxYear); IInfo <IInfo> sut = CreateSut(year, month); short differentMonthAfter = GetNonMatchingMonthAfter(month); DateTime statusDate = new DateTime(year, differentMonthAfter, _random.Next(1, DateTime.DaysInMonth(year, differentMonthAfter))); IInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.IsYearToDateOfStatusDate, Is.True); }
public async Task IsLastMonthOfStatusDate_WhenStatusDateIsDifferentYearThanNextMonthOfInfo_ReturnsFalse(short month) { short year = (short)_random.Next(Sut.MinYear, Sut.MaxYear - 1); IInfo <IInfo> sut = CreateSut(year, month); short differentYear = GetNonMatchingYear((short)sut.ToDate.AddDays(1).Year); DateTime statusDate = new DateTime(differentYear, sut.ToDate.AddDays(1).Month, _random.Next(1, DateTime.DaysInMonth(differentYear, sut.ToDate.AddDays(1).Month))); IInfo result = await sut.CalculateAsync(statusDate); Assert.That(result.IsLastMonthOfStatusDate, Is.False); }
public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_AssertAlreadyCalculatedWasCalledTwiceOnSut() { IInfo <IInfo> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); Sut result = (Sut)await((IInfo <IInfo>)await((IInfo <IInfo>) await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate); Assert.That(result.AlreadyCalculatedWasCalledTimes, Is.EqualTo(2)); }
public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_ReturnsSameInfo() { IInfo <IInfo> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IInfo <IInfo> result = (IInfo <IInfo>)await((IInfo <IInfo>)await((IInfo <IInfo>) await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate); Assert.That(result, Is.SameAs(sut)); }