private async Task AreDataLockFieldsStoredCorrectly(IList <DataLockEvent> expectedDataLockEvents) { var actualDataLocks = (await EventTestsRepository.GetDataLocks()).OrderBy(d => d.DataLockId).ToList(); var actualDataLockErrors = (await EventTestsRepository.GetDataLockErrors()).OrderBy(e => e.DataLockId).ThenBy(e => e.ErrorCode).ToList(); for (var i = 0; i < actualDataLocks.Count; i++) { Assert.AreEqual(expectedDataLockEvents[i].Id, actualDataLocks[i].DataLockId); var expectedDataLock = expectedDataLockEvents[i]; var actualDataLock = actualDataLocks[i]; Assert.AreEqual(expectedDataLock.ProcessDateTime, actualDataLock.ProcessDateTime); Assert.AreEqual(expectedDataLock.Status, actualDataLock.Status); Assert.AreEqual(expectedDataLock.IlrFileName, actualDataLock.IlrFileName); Assert.AreEqual(expectedDataLock.Ukprn, actualDataLock.UkPrn); Assert.AreEqual(expectedDataLock.Uln, actualDataLock.Uln); Assert.AreEqual(expectedDataLock.LearnRefNumber, actualDataLock.LearnRefNumber); Assert.AreEqual(expectedDataLock.AimSeqNumber, actualDataLock.AimSeqNumber); Assert.AreEqual(expectedDataLock.PriceEpisodeIdentifier, actualDataLock.PriceEpisodeIdentifier); Assert.AreEqual(expectedDataLock.ApprenticeshipId, actualDataLock.ApprenticeshipId); Assert.AreEqual(expectedDataLock.EmployerAccountId, actualDataLock.EmployerAccountId); Assert.AreEqual(expectedDataLock.EventSource, actualDataLock.EventSource); Assert.AreEqual(expectedDataLock.IlrStartDate, actualDataLock.IlrStartDate); Assert.AreEqual(expectedDataLock.IlrStandardCode, actualDataLock.IlrStandardCode); Assert.AreEqual(expectedDataLock.IlrProgrammeType, actualDataLock.IlrProgrammeType); Assert.AreEqual(expectedDataLock.IlrFrameworkCode, actualDataLock.IlrFrameworkCode); Assert.AreEqual(expectedDataLock.IlrPathwayCode, actualDataLock.IlrPathwayCode); Assert.AreEqual(expectedDataLock.IlrTrainingPrice, actualDataLock.IlrTrainingPrice); Assert.AreEqual(expectedDataLock.IlrEndpointAssessorPrice, actualDataLock.IlrEndpointAssessorPrice); Assert.AreEqual(expectedDataLock.IlrPriceEffectiveFromDate, actualDataLock.IlrPriceEffectiveFromDate); Assert.AreEqual(expectedDataLock.IlrPriceEffectiveToDate, actualDataLock.IlrPriceEffectiveToDate); Assert.AreEqual(true, actualDataLock.IsLatest); //Check errors var actualErrors = actualDataLockErrors.Where(e => e.DataLockId == actualDataLock.Id).OrderBy(e => e.ErrorCode) .ToList(); Assert.AreEqual(expectedDataLock.Errors.Length, actualErrors.Count); foreach (var expectedError in expectedDataLock.Errors) { var actualError = actualErrors.SingleOrDefault(e => e.ErrorCode == expectedError.ErrorCode); Assert.IsNotNull(actualError); Assert.AreEqual(expectedError.SystemDescription, actualError.SystemDescription); } } }