예제 #1
0
        public async Task GettingRecordsByInsolvencyOrderId_WithPageInformation_ReturnsExpectedNumberOfRecords(
            int currentPage,
            int pageSize,
            int insolvencyOrderId,
            int expected)
        {
            // Arrange
            var pageInformation   = new PageInformation(currentPage, pageSize);
            var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals();
            var personRecords     = PersonsTestData.CreatePersonsActuals();
            var context           = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(personRecords);

            var personRepository = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actualCount =
                (await personRepository.GetResultsByAsync(
                     insolvencyOrderId,
                     record => record.InsolvencyOrderId,
                     pageInformation))
                .Count();

            // Assert
            Assert.AreEqual(expected, actualCount);
        }
예제 #2
0
        public async Task GettingRecordsByInsolvencyOrderId_WithPageInformation_ReturnsMappedModels(
            int currentPage,
            int pageSize,
            int insolvencyOrderId)
        {
            // Arrange
            var pageInformation   = new PageInformation(currentPage, pageSize);
            var expecteds         = PersonsTestData.GetExpectedsByInsolvencyOrderId(pageInformation, insolvencyOrderId);
            var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals();
            var personRecords     = PersonsTestData.CreatePersonsActuals();
            var context           = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(personRecords);

            var personRepository = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actuals =
                await personRepository.GetResultsByAsync(
                    insolvencyOrderId,
                    record => record.InsolvencyOrderId,
                    pageInformation);

            // Assert
            CollectionAssert.AreEqual(
                expecteds.OrderBy(x => x.InsolvencyOrderPersonId).ToList(),
                actuals.OrderBy(x => x.InsolvencyOrderPersonId).ToList(),
                new InsolvencyPersonModelComparer());
        }
예제 #3
0
        public async Task CountingAllRecords_WithSeededPersonsRecords_ReturnsCorrectCount(int records)
        {
            // Arrange
            var personRecords    = PersonsDataCreationFixture.CreateMany(records);
            var context          = TestDbContext.CreateContextWithSeededData(personRecords);
            var personRepository = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actualCount = await personRepository.CountAsync();

            // Assert
            Assert.AreEqual(records, actualCount);
        }
예제 #4
0
        public async Task CountingRecordsById_WithSeededPersonsRecords_ReturnsCorrectCount()
        {
            // Arrange
            const int recordId      = 1;
            const int expectedCount = 1;

            var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals();
            var personRecords     = PersonsTestData.CreatePersonsActuals();
            var context           = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(personRecords);
            var personRepository  = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actualCount = await personRepository.CountByAsync(recordId, record => record.InsolvencyOrderPersonId);

            // Assert
            Assert.AreEqual(expectedCount, actualCount);
        }
예제 #5
0
        public async Task GettingAllRecords_WithSeededPersonsRecords_ReturnsMappedModels()
        {
            // Arrange
            var pageInformation   = new PageInformation(1, 100);
            var expectedRecords   = PersonsTestData.CreatePersonsExpecteds();
            var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals();
            var personRecords     = PersonsTestData.CreatePersonsActuals();
            var context           = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(personRecords);

            var personRepository = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actualRecords = await personRepository.GetAllAsync(pageInformation);

            // Assert
            CollectionAssert.AreEqual(
                expectedRecords.OrderBy(x => x.InsolvencyOrderPersonId).ToList(),
                actualRecords.OrderBy(x => x.InsolvencyOrderPersonId).ToList(),
                new InsolvencyPersonModelComparer());
        }
예제 #6
0
        public async Task GettingRecordById_WithSeededPersonsRecords_ReturnsMappedModel()
        {
            // Arrange
            const int recordId = 1;

            var expectedRecord    = PersonsTestData.GetPersonsById(recordId);
            var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals();
            var personRecords     = PersonsTestData.CreatePersonsActuals();
            var context           = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(personRecords);

            var personRepository = new InsolvencyOrderPersonsRepository(context, mockTelemetryClient.Object);

            // Act
            var actualRecord = await personRepository.GetResultByAsync(recordId, record => record.InsolvencyOrderPersonId);

            // Assert
            Assert.AreEqual(expectedRecord.InsolvencyOrderId, actualRecord.InsolvencyOrderId);
            Assert.AreEqual(expectedRecord.Forename, actualRecord.Forename);
            Assert.AreEqual(expectedRecord.InsolvencyOrderPersonId, actualRecord.InsolvencyOrderPersonId);
            Assert.AreEqual(expectedRecord.Surname, actualRecord.Surname);
            Assert.AreEqual(expectedRecord.Title, actualRecord.Title);
            Assert.AreEqual(expectedRecord.DateOfBirth, actualRecord.DateOfBirth);
        }