Exemplo n.º 1
0
        public void TestExportTwoLines()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello,", LevelFlags.Other);
            logFile.AddEntry("World!", LevelFlags.Other);
            var exporter = new LogFileToFileExporter(logFile, _directory, "foo");

            exporter.FullExportFilename.Should().BeNull("because the full filename must be determined from inside Export, NOT beforehand");
            new Action(() => exporter.Export()).Should().NotThrow();
            exporter.FullExportFilename.Should().NotBeNull();
            exporter.FullExportFilename.Should().StartWith(_directory);

            GetString(exporter.FullExportFilename).Should().Be("Hello,\r\nWorld!");
        }
Exemplo n.º 2
0
        public void TestExportTwice()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello", LevelFlags.Other);
            var exporter1 = new LogFileToFileExporter(logFile, _directory, "foo");

            exporter1.Export();

            logFile.AddEntry("World!", LevelFlags.Other);
            var exporter2 = new LogFileToFileExporter(logFile, _directory, "foo");

            new Action(() => exporter2.Export()).Should().NotThrow();

            exporter1.FullExportFilename.Should()
            .NotBe(exporter2.FullExportFilename,
                   "because previous exports should not be overwritten");

            GetString(exporter1.FullExportFilename).Should().Be("Hello");
            GetString(exporter2.FullExportFilename).Should().Be("Hello\r\nWorld!");
        }