예제 #1
0
 public Metadata(
     ILogger <Metadata> logger,
     IFileSystem fileSystem,
     FileMatcher fileMatcher,
     OutputRecordWriter writer,
     MetadataRegister register)
 {
     this.logger            = logger;
     this.fileSystem        = fileSystem;
     this.fileMatcher       = fileMatcher;
     this.writer            = writer;
     this.extractorRegister = register;
 }
예제 #2
0
        public void OutputWriterWriteCsv()
        {
            var stringBuilder = new StringBuilder(4);

            using var stringWriter = new StringWriter(stringBuilder);
            var csvSerializer = new CsvSerializer();

            var output = new OutputRecordWriter(stringWriter, csvSerializer);

            // generate a fake and write it to the stream
            var a = this.fakes.Recording.Generate();

            output.Write(a);

            // check the header was written
            var actual = stringBuilder.ToString();

            Assert.StartsWith($"{nameof(Recording.SourcePath)},", actual);
            Assert.Contains(a.ExpectedDurationSeconds?.TotalSeconds.ToString(), actual);

            // generate and write another fake
            var b = this.fakes.Recording.Generate();

            output.Write(b);

            // finish writing
            output.Dispose();

            actual = stringBuilder.ToString();
            Assert.StartsWith($"{nameof(Recording.SourcePath)},", actual);
            Assert.Single(Regex.Matches(actual, $"{nameof(Recording.SourcePath)},"));
            Assert.Contains(a.ExpectedDurationSeconds?.TotalSeconds.ToString(), actual);

            var records = csvSerializer.Deserialize <Recording>(new StringReader(actual)).ToArray();

            Assert.Equal(records[0].SourcePath, a.SourcePath);
            Assert.Equal(records[1].SourcePath, b.SourcePath);
        }
예제 #3
0
        public void OutputWriterWriteJson()
        {
            var stringBuilder = new StringBuilder(4);

            using var stringWriter = new StringWriter(stringBuilder);
            var jsonSerializer = new JsonSerializer();

            var output = new OutputRecordWriter(stringWriter, jsonSerializer);

            // generate a fake and write it to the stream
            var a = this.fakes.Recording.Generate();

            output.Write(a);

            // check the header was written
            var actual = stringBuilder.ToString();

            Assert.StartsWith($"[{Environment.NewLine}", actual);
            Assert.EndsWith("}", actual);

            // generate and write another fake
            var b = this.fakes.Recording.Generate();

            output.Write(b);

            // finish writing
            output.Dispose();

            actual = stringBuilder.ToString();
            Assert.StartsWith($"[{Environment.NewLine}", actual);
            Assert.EndsWith("]", actual);

            var records = jsonSerializer.Deserialize <Recording>(new StringReader(actual)).ToArray();

            Assert.Equal(records[0].SourcePath, a.SourcePath);
            Assert.Equal(records[1].SourcePath, b.SourcePath);
        }
예제 #4
0
 public FixList(OutputRecordWriter writer)
 {
     this.Writer = writer;
 }
예제 #5
0
 public FixApply(ILogger <FixApply> logger, ILogger <DryRun> dryRunLogger, FileMatcher fileMatcher, FixRegister register, OutputRecordWriter writer, IFileSystem fileSystem)
 {
     this.logger       = logger;
     this.dryRunLogger = dryRunLogger;
     this.fileMatcher  = fileMatcher;
     this.register     = register;
     this.fileSystem   = fileSystem;
     this.Writer       = writer;
 }
예제 #6
0
 public FixCheck(IConsole console, ILogger <FixCheck> logger, FileMatcher fileMatcher, FixRegister register, OutputRecordWriter writer, IFileSystem fileSystem)
 {
     this.console     = console;
     this.logger      = logger;
     this.fileMatcher = fileMatcher;
     this.register    = register;
     this.fileSystem  = fileSystem;
     this.Writer      = writer;
 }
예제 #7
0
 public Version(OutputRecordWriter writer)
 {
     this.Writer = writer;
 }
예제 #8
0
 public Rename(ILogger <Rename> logger, ILogger <DryRun> dryRunLogger, IFileSystem fileSystem, FileMatcher fileMatcher, OutputRecordWriter writer, FilenameParser parser)
 {
     this.logger       = logger;
     this.dryRunLogger = dryRunLogger;
     this.fileSystem   = fileSystem;
     this.fileMatcher  = fileMatcher;
     this.parser       = parser;
     this.Writer       = writer;
     this.fileSystem   = fileSystem;
     this.fileSystem   = fileSystem;
 }