public EclIngestionWorker(BulkIngestionRepository repository, IIngestionServiceConfiguration configuration, EclIngestionHelper helper, FileHelper fileHelper) { this.repository = repository; this.configuration = configuration; this.ingestionHelper = helper; this.fileHelper = fileHelper; }
public void GetFileState_WhenFileEndsWithDotVIC_ThenReturnVIC() { string expected = State.VIC; var helper = new EclIngestionHelper(); string actual = helper.GetFileState("MO.something.VIC"); Assert.AreEqual(expected, actual); }
public void GetRecordType_WhenRecordStartsWithZ_ThenReturnFooter() { string expectedRecordType = RecordType.FOOTER; var helper = new EclIngestionHelper(); string actualRecordType = helper.GetRecordType("Z"); Assert.AreEqual(expectedRecordType, actualRecordType); }
public void GetRecordType_WhenRecordStartsWithC_ThenReturnInvalid() { string expectedRecordType = RecordType.INVALID; var helper = new EclIngestionHelper(); string actualRecordType = helper.GetRecordType("C"); Assert.AreEqual(expectedRecordType, actualRecordType); }
public void GetRecordType_WhenRecordStartsWithA_ThenReturnHeader() { string expectedRecordType = RecordType.HEADER; var helper = new EclIngestionHelper(); string actualRecordType = helper.GetRecordType("A"); Assert.AreEqual(expectedRecordType, actualRecordType); }
public void GetRecordType_WhenRecordStartsWithD_ThenReturnData() { string expectedRecordType = RecordType.DATA; var helper = new EclIngestionHelper(); string actualRecordType = helper.GetRecordType("D"); Assert.AreEqual(expectedRecordType, actualRecordType); }
public void Process_WhenHeaderIsInvalid_ThenExpectException() { LogContext.PermitCrossAppDomainCalls = true; var repository = new Mock<BulkIngestionRepository>("connectionString"); var configuration = new Mock<IIngestionServiceConfiguration>(); var ingestionHelper = new EclIngestionHelper(); var fileHelper = new Mock<FileHelper>(); fileHelper.Setup(f => f.GetFileName(It.IsAny<string>())).Returns("file1.VIC"); fileHelper.Setup(f => f.GetEclFiles(It.IsAny<string>())).Returns(new string[] { "file1.VIC" }); fileHelper.Setup(f => f.ReadAllLines(It.IsAny<string>())).Returns(new string[] { "A2 A", "D032820 190475 000402864000000000000000003850006M10/11/15 082037 082265 149000044 06 Z 082265 020388500", "Z000001 Z" }); var worker = new EclIngestionWorker(repository.Object, configuration.Object, ingestionHelper, fileHelper.Object); worker.Process(); }
public void Process_WhenContains1File_Then1FileIsBulkImported() { LogContext.PermitCrossAppDomainCalls = true; var repository = new Mock<BulkIngestionRepository>("connectionString"); var configuration = new Mock<IIngestionServiceConfiguration>(); var ingestionHelper = new EclIngestionHelper(); var fileHelper = new Mock<FileHelper>(); fileHelper.Setup(f => f.GetFileName(It.IsAny<string>())).Returns("file1.VIC"); fileHelper.Setup(f => f.GetEclFiles(It.IsAny<string>())).Returns(new string[] { "file1.VIC" }); fileHelper.Setup(f => f.ReadAllLines(It.IsAny<string>())).Returns(new string[] { "A220151110 A", "D032820 190475 000402864000000000000000003850006M10/11/15 082037 082265 149000044 06 Z 082265 020388500", "Z000001 Z" }); var worker = new EclIngestionWorker(repository.Object, configuration.Object, ingestionHelper, fileHelper.Object); worker.Process(); repository.Verify(v => v.BulkImportEclData(It.IsAny<IList<AusPostEclData>>(), It.IsAny<string>()), Times.Once); }
public void GetFileDate_WhenHeaderFormatIsInvalid_ThenReturnNull() { DateTime? expected = null; var helper = new EclIngestionHelper(); var actual = helper.GetFileDate("A"); Assert.AreEqual(expected, actual); }
public void GetFileDate_WhenHeaderHasAnInvalidDateInDDMMYYYYFormat_ThenReturnNull() { DateTime? expected = null; var helper = new EclIngestionHelper(); var actual = helper.GetFileDate("A225122015"); Assert.AreEqual(expected, actual); }
public void GetFileDate_WhenHeaderHasAValidDateInYYYYMMDDFormat_ThenReturnDateTime() { DateTime expected = new DateTime(2015, 12, 25); var helper = new EclIngestionHelper(); var actual = helper.GetFileDate("A220151225"); Assert.AreEqual(expected, actual); }
public void GetFileState_WhenFileEndsWithDotNT_ThenReturnINVALID() { string expected = State.INVALID; var helper = new EclIngestionHelper(); string actual = helper.GetFileState("MO.something.NT"); Assert.AreEqual(expected, actual); }
public void GetFileState_WhenFileIsEmpty_ThenReturnINVALID() { string expected = State.INVALID; var helper = new EclIngestionHelper(); string actual = helper.GetFileState(""); Assert.AreEqual(expected, actual); }