public async Task GettingAllRecords_WithPageInformation_ReturnsMappedModels(int currentPage, int pageSize) { // Arrange var pageInformation = new PageInformation(currentPage, pageSize); var expectedRecords = InsolvenciesTestData.CreateInsolvenciesExpecteds(pageInformation).ToList(); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords); var operationDateProvider = new Mock <IOperationDateProvider>(); operationDateProvider.Setup(x => x.GetOperationDate()).Returns(DateTime.Now); IOptions <RetentionOptions> retentionOptions = new ConfigurationOption( new RetentionOptions() { RetentionPeriod = 10, CutOffPeriod = 6 }); var insolvencyOrdersFilteredBaseData = new InsolvencyOrderFilterContext(retentionOptions, operationDateProvider.Object); var disputesFilteredBaseData = new DisputeFilterContext(retentionOptions, operationDateProvider.Object); var insolvencyOrdersRepository = new InsolvencyOrdersRepository( context, insolvencyOrdersFilteredBaseData, disputesFilteredBaseData, mockTelemetryClient.Object); // Act var actualRecords = (await insolvencyOrdersRepository.GetAllAsync(pageInformation)).ToList(); // Assert CollectionAssert.AreEqual(expectedRecords, actualRecords, new InsolvencyModelComparer()); }
public async Task GettingAllRecords_WithDisputes_ReturnsInsolvenciesRecordsWithFilteredDisputes() { // Arrange const string includes = DomainResources.Disputes; var pageInformation = new PageInformation(1, 100); var expectedInsolvenciesRecords = InsolvenciesWithDisputesTestData.CreateInsolvenciesExpecteds(); var expectedDisputeRecords = expectedInsolvenciesRecords.SelectMany(insolvencyModel => insolvencyModel.Disputes); var insolvencyRecords = InsolvenciesWithDisputesTestData.CreateInsolvenciesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords); var operationDateProvider = new Mock <IOperationDateProvider>(); operationDateProvider.Setup(x => x.GetOperationDate()).Returns(DateTime.Now); IOptions <RetentionOptions> retentionOptions = new ConfigurationOption( new RetentionOptions() { RetentionPeriod = 10, CutOffPeriod = 6 }); var insolvencyOrdersFilteredBaseData = new InsolvencyOrderFilterContext(retentionOptions, operationDateProvider.Object); var disputesFilteredBaseData = new DisputeFilterContext(retentionOptions, operationDateProvider.Object); var insolvencyOrdersRepository = new InsolvencyOrdersRepository( context, insolvencyOrdersFilteredBaseData, disputesFilteredBaseData, mockTelemetryClient.Object); // Act var actualInsolvenciesRecords = await insolvencyOrdersRepository.GetAllAsync(pageInformation, includes); var actualDisputeRecords = actualInsolvenciesRecords.SelectMany(insolvencyModel => insolvencyModel.Disputes); // Assert CollectionAssert.AreEqual(expectedInsolvenciesRecords.ToList(), actualInsolvenciesRecords.ToList(), new InsolvencyModelComparer()); CollectionAssert.AreEqual(expectedDisputeRecords.ToList(), actualDisputeRecords.ToList(), new DisputeModelComparer()); }