コード例 #1
0
        public void TestOutputOverwritingWithoutClobber()
        {
            this.TestFiles.AddEmptyFile("output.txt");

            var sink = new OutputSink(
                this.BuildLogger <OutputSink>(),
                new EmuGlobalOptions()
            {
                Output = "output.txt",
            },
                this.TestFiles);

            var action = () => sink.Create();

            action.Should().Throw <InvalidOperationException>()
            .WithMessage("File exists and clobber not specified");
        }
コード例 #2
0
        public void TestOutput()
        {
            this.TestFiles.AddDirectory("/abc");
            this.TestFiles.Directory.SetCurrentDirectory(this.ResolvePath("/abc"));

            var sink = new OutputSink(
                this.BuildLogger <OutputSink>(),
                new EmuGlobalOptions()
            {
                Output = "output.txt",
            },
                this.TestFiles);

            sink.Create();

            // relative paths should resolve to the current working directory
            this.TestFiles.FileExists("/abc/output.txt").Should().BeTrue();
        }
コード例 #3
0
        public void TestOutputOverwriting()
        {
            this.TestFiles.AddEmptyFile("output.txt");

            var sink = new OutputSink(
                this.BuildLogger <OutputSink>(),
                new EmuGlobalOptions()
            {
                Output  = "output.txt",
                Clobber = true,
            },
                this.TestFiles);

            sink.Create();

            this.TestFiles.FileExists("/output.txt").Should().BeTrue();
            var expectedPath = this.ResolvePath("/output.txt");

            this.Loggers.Single().Entries.Single().Message.Should().Be($"Overwriting {expectedPath} because --clobber was specified");
        }
コード例 #4
0
        public void TestOutputIntermediateDirectoryCreation()
        {
            var sink = new OutputSink(
                this.BuildLogger <OutputSink>(),
                new EmuGlobalOptions()
            {
                Output = "/subdir/anotherdir/output.txt",
            },
                this.TestFiles);

            var beforeDirs = this.TestFiles.AllDirectories;

            sink.Create();

            var afterDirs = beforeDirs.Concat(new[]
            {
                "/subdir",
                "/subdir/anotherdir",
            }).Select(this.ResolvePath);

            this.TestFiles.AllDirectories.Should().Equal(afterDirs);
        }