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 addresses = AddressesTestData.CreateAddressesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actualCount = (await addressesRepository.GetResultsByAsync( insolvencyOrderId, record => record.InsolvencyOrderId, pageInformation)) .Count(); // Assert Assert.AreEqual(expected, actualCount); }
public async Task GettingRecordsByInsolvencyOrderId_WithPageInformation_ReturnsMappedModels( int currentPage, int pageSize, int insolvencyOrderId) { // Arrange var pageInformation = new PageInformation(currentPage, pageSize); var expecteds = AddressesTestData.GetExpectedsByInsolvencyOrderId(pageInformation, insolvencyOrderId); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var addresses = AddressesTestData.CreateAddressesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actuals = await addressesRepository.GetResultsByAsync( insolvencyOrderId, record => record.InsolvencyOrderId, pageInformation); // Assert CollectionAssert.AreEqual( expecteds.OrderBy(x => x.InsolvencyOrderAddressId).ToList(), actuals.OrderBy(x => x.InsolvencyOrderAddressId).ToList(), new InsolvencyAddressModelComparer()); }
public async Task CountingAllRecords_WithSeededAddressesRecords_ReturnsCorrectCount(int records) { // Arrange var addresses = AddressesDataCreationFixture.CreateMany(records); var context = TestDbContext.CreateContextWithSeededData(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actualCount = await addressesRepository.CountAsync(); // Assert Assert.AreEqual(records, actualCount); }
public async Task CountingRecordsById_WithSeededAddressesRecords_ReturnsCorrectCount() { // Arrange const int recordId = 1; const int expectedCount = 1; var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var addresses = AddressesTestData.CreateAddressesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actualCount = await addressesRepository.CountByAsync(recordId, record => record.InsolvencyOrderAddressId); // Assert Assert.AreEqual(expectedCount, actualCount); }
public async Task GettingAllRecords_WithSeededAddressesRecords_ReturnsMappedModels() { // Arrange var pageInformation = new PageInformation(1, 100); var expectedRecords = AddressesTestData.CreateAddressesExpecteds(); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var addresses = AddressesTestData.CreateAddressesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actualRecords = await addressesRepository.GetAllAsync(pageInformation); // Assert CollectionAssert.AreEqual( expectedRecords.OrderBy(x => x.InsolvencyOrderAddressId).ToList(), actualRecords.OrderBy(x => x.InsolvencyOrderAddressId).ToList(), new InsolvencyAddressModelComparer()); }
public async Task GettingRecordById_WithSeededAddressesRecords_ReturnsMappedModel() { // Arrange const int recordId = 1; var expectedRecord = AddressesTestData.GetAddressesById(recordId); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var addresses = AddressesTestData.CreateAddressesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords).Seed(addresses); var addressesRepository = new InsolvencyOrderAddressesRepository(context, mockTelemetryClient.Object); // Act var actualRecord = await addressesRepository.GetResultByAsync(recordId, record => record.InsolvencyOrderAddressId); // Assert Assert.AreEqual(expectedRecord.InsolvencyOrderId, actualRecord.InsolvencyOrderId); Assert.AreEqual(expectedRecord.PostCode, actualRecord.PostCode); Assert.AreEqual(expectedRecord.InsolvencyOrderAddressId, actualRecord.InsolvencyOrderAddressId); Assert.AreEqual(expectedRecord.Address, actualRecord.Address); }