示例#1
0
        public void SetToWriteMatchedAndUnmatchedFixedWidthRecordsThatAreInDataFile()
        {
            String inputFilePath = null;
              String matchedOutputFilePath = null;
              String unmatchedOutputFilePath = null;
              String logFilePath = null;

              try
              {
            // Arrange
            CreateFilePathsForFixedWidthTests(out inputFilePath, out matchedOutputFilePath, out unmatchedOutputFilePath, out logFilePath);

            Assembly.GetExecutingAssembly().CopyEmbeddedResourceToFile("Siftan.AcceptanceTests.FixedWidthRecordFile.txt", inputFilePath);

            var outputWriter = new OneFileRecordWriter(matchedOutputFilePath, unmatchedOutputFilePath, new StatisticsManager());

            // Act
            new Engine().Execute(
              new[] { inputFilePath },
              new LogManager(null, null),
              new FileReaderFactory(),
              CreateFixedWidthRecordReader(),
              new InListExpression(new[] { "12345" }),
              outputWriter,
              null,
              null);

            // Assert
            this.AssertLogfileIsCorrect(logFilePath);

            File.Exists(matchedOutputFilePath).ShouldBeTrue();
            var lines = File.ReadAllLines(matchedOutputFilePath);
            lines.Length.ShouldBe(5);
            lines[0].ShouldBe("01Ben Toynbee123451.23");
            lines[1].ShouldBe("02           12345");
            lines[2].ShouldBe("03           12345");
            lines[3].ShouldBe("03           12345");
            lines[4].ShouldBe("05           12345");

            File.Exists(unmatchedOutputFilePath).ShouldBeTrue();
            lines = File.ReadAllLines(unmatchedOutputFilePath);
            lines.Length.ShouldBe(4);
            lines[0].ShouldBe("01Sid Sample 543211.23");
            lines[1].ShouldBe("02           54321");
            lines[2].ShouldBe("03           54321");
            lines[3].ShouldBe("05           54321");
              }
              finally
              {
            DeleteDirectoryContainingFile(inputFilePath);
              }
        }
示例#2
0
        public void SetToWriteMatchedDelimitedRecordsThatAreNotInDataFile()
        {
            String inputFilePath = null;
              String matchedOutputFilePath = null;
              String unmatchedOutputFilePath = null;
              String logFilePath = null;

              try
              {
            // Arrange
            CreateFilePathsForDelimitedTests(out inputFilePath, out matchedOutputFilePath, out unmatchedOutputFilePath, out logFilePath);

            Assembly.GetExecutingAssembly().CopyEmbeddedResourceToFile("Siftan.AcceptanceTests.DelimitedRecordFile.csv", inputFilePath);

            var outputWriter = new OneFileRecordWriter(matchedOutputFilePath, null, new StatisticsManager());

            // Act
            new Engine().Execute(
              new[] { inputFilePath },
              new LogManager(null, null),
              new FileReaderFactory(),
              CreateDelimitedRecordReader(),
              new InListExpression(new[] { "11111" }),
              outputWriter,
              null,
              null);

            // Assert
            this.AssertLogfileIsCorrect(logFilePath);

            File.Exists(matchedOutputFilePath).ShouldBeFalse();
              }
              finally
              {
            DeleteDirectoryContainingFile(inputFilePath);
              }
        }