public async Task FetchAatfByReturnId_GivenReturnId_ReturnedListShouldOnlyContainReturnRelatedAatfs() { using (var database = new DatabaseWrapper()) { var helper = new ModelHelper(database.Model); var domainHelper = new DomainHelper(database.WeeeContext); var dataAccess = new FetchAatfDataAccess(database.WeeeContext, quarterWindowFactory); var genericDataAccess = new GenericDataAccess(database.WeeeContext); var aatf = await CreateAatf(database, FacilityType.Aatf, DateTime.Now, 2019); var @return = new EA.Weee.Domain.AatfReturn.Return(aatf.Organisation, new Quarter(2019, QuarterType.Q1), database.WeeeContext.Users.First().Id, FacilityType.Aatf); await genericDataAccess.Add(new ReturnAatf(aatf, @return)); var @return2 = new EA.Weee.Domain.AatfReturn.Return(aatf.Organisation, new Quarter(2019, QuarterType.Q1), database.WeeeContext.Users.First().Id, FacilityType.Aatf); var aatf2 = await CreateAatf(database, FacilityType.Aatf, DateTime.Now, 2019); await genericDataAccess.Add(new ReturnAatf(aatf2, @return2)); var aatfList = await dataAccess.FetchAatfByReturnId(@return.Id); aatfList.Count.Should().Be(1); aatfList.Should().Contain(aatf); aatfList.Should().NotContain(aatf2); } }
public async Task FetchAatfByReturnId_GivenMatchingParameters_AatfsShouldBeOrderedByName() { using (var database = new DatabaseWrapper()) { var helper = new ModelHelper(database.Model); var domainHelper = new DomainHelper(database.WeeeContext); var dataAccess = new FetchAatfDataAccess(database.WeeeContext, quarterWindowFactory); var genericDataAccess = new GenericDataAccess(database.WeeeContext); var aatfList = await CreateMultipleAatf(database, FacilityType.Aatf, DateTime.Now, 2019); var @return = new Return(aatfList[0].Organisation, new Quarter(2019, QuarterType.Q1), "created", FacilityType.Aatf); A.CallTo(() => quarterWindowFactory.GetQuarterWindow(@return.Quarter)).Returns(new QuarterWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1), QuarterType.Q1)); await genericDataAccess.AddMany <Aatf>(aatfList); var returnedAatfList = await dataAccess.FetchAatfByReturnId(@return.Id); aatfList.Should().BeInDescendingOrder(m => m.Name); } }