public async Task GettingRecordById_WithDisputesAndPageInformation_ReturnsInsolvenciesRecordsWithFilteredDisputes()
        {
            // Arrange
            const int    recordId                 = 1;
            const string includes                 = DomainResources.Disputes;
            var          pageInformation          = new PageInformation(1, 100);
            var          expectedInsolvencyRecord =
                new List <InsolvencyOrderModel> {
                InsolvenciesWithDisputesTestData.GetInsolvencyById(recordId)
            };
            var expectedDisputeRecords = expectedInsolvencyRecord.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 actualInsolvencyRecord =
                await insolvencyOrdersRepository.GetResultsByAsync(
                    recordId,
                    record => record.InsolvencyOrderId,
                    pageInformation,
                    includes);

            var actualDisputeRecord = actualInsolvencyRecord.SelectMany(insolvencyModel => insolvencyModel.Disputes);

            // Assert
            CollectionAssert.AreEqual(
                expectedInsolvencyRecord.ToList(),
                actualInsolvencyRecord.ToList(),
                new InsolvencyModelComparer());
            CollectionAssert.AreEqual(
                expectedDisputeRecords.ToList(),
                actualDisputeRecord.ToList(),
                new DisputeModelComparer());
        }
        public async Task GettingRecordsByResidenceId_WithPageInformation_ReturnsMappedModels(
            int currentPage,
            int pageSize,
            int residenceId)
        {
            // Arrange
            var pageInformation       = new PageInformation(currentPage, pageSize);
            var expecteds             = InsolvenciesTestData.GetExpectedsByResidenceId(pageInformation, residenceId);
            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 actuals =
                await insolvencyOrdersRepository.GetResultsByAsync(
                    residenceId,
                    record => record.ResidenceId,
                    pageInformation);

            // Assert
            CollectionAssert.AreEqual(
                expecteds.OrderBy(x => x.InsolvencyOrderId).ToList(),
                actuals.OrderBy(x => x.InsolvencyOrderId).ToList(),
                new InsolvencyModelComparer());
        }