public async Task GetDinners_TwoDinnerPlanned_FillUnplannedInterpolated() { // Arrange var fixture = Fixture; fixture.Inject(new LocalDate(2021, 1, 2)); var dinner = fixture.Build <Dinner>() .Create(); fixture.Inject(new LocalDate(2021, 1, 4)); var dinner2 = fixture.Build <Dinner>() .Create(); _mockRepo.Setup(s => s.GetAsync(_familyId, _fromDate, _toDate)).Returns(new[] { dinner, dinner2 }.ToAsyncEnumerable()); var sut = new DinnerService(_mockRepo.Object); // Act var dinners = await sut.GetAsync(_familyId, _fromDate, _toDate).ToListAsync(); // Assert Assert.Equal(7, dinners.Count); Assert.Equal(dinner.Id, dinners[1].Id); Assert.Equal(dinner2.Id, dinners[3].Id); Assert.Equal(_fromDate, dinners.First().Date); Assert.Equal(_toDate, dinners.Last().Date); }
public async Task GetDinners_NoDinnersInRepo_FullRangeUnplannedReturned() { // Arrange _mockRepo.Setup(s => s.GetAsync(_familyId, _fromDate, _toDate)).Returns(Array.Empty <Dinner>().ToAsyncEnumerable()); var sut = new DinnerService(_mockRepo.Object); // Act var dinners = await sut.GetAsync(_familyId, _fromDate, _toDate).ToListAsync(); // Assert Assert.Equal(7, dinners.Count); Assert.Equal(_fromDate, dinners.First().Date); Assert.Equal(_toDate, dinners.Last().Date); }
public async Task GetDinners_AllDinnersPlanned_NoFill() { // Arrange var fixture = Fixture; _mockRepo.Setup(s => s.GetAsync(_familyId, _fromDate, _toDate)).Returns(CreateDinners(fixture, _fromDate, _toDate).ToAsyncEnumerable()); var sut = new DinnerService(_mockRepo.Object); // Act var dinners = await sut.GetAsync(_familyId, _fromDate, _toDate).ToListAsync(); // Assert Assert.Equal(7, dinners.Count); Assert.Equal(_fromDate, dinners.First().Date); Assert.Equal(_toDate, dinners.Last().Date); }