예제 #1
0
        public void Should_support_Optimize_flag()
        {
            var fileSystem = new FileSystemStub();
            var environment = new ExecutionEnvironmentStub();
            var compiler = new CSharpCompilerTask(fileSystem, environment);

            compiler.Optimize = true;
            environment.RunHandler = (fileName, arguments, x) =>
            {
                arguments.Contains(" /optimize+").ShouldBe(true);
            };
            compiler.Output = new Path("MyAssembly.dll");
            compiler.Execute();
        }
예제 #2
0
        public void Should_create_target_directory_if_not_present()
        {
            var fileSystem = new FileSystemStub();
            var environment = new ExecutionEnvironmentStub();

            var compiler = new CSharpCompilerTask(fileSystem, environment);
            var outDir = new Path("Build").Combine("Debug");
            compiler.Output = outDir.Combine("Pencil.Build.dll");
            Path createdDirectory = Path.Empty;

            fileSystem.DirectoryExistsHandler = x => false;
            fileSystem.CreateDirectoryHandler = x => createdDirectory = new Path(x);
            compiler.Execute();

            outDir.ShouldEqual(createdDirectory);
        }
예제 #3
0
        public void Wont_copy_referenced_assemblies_already_present()
        {
            var fileSystem = new FileSystemStub();
            var environment = new ExecutionEnvironmentStub();

            var compiler = new CSharpCompilerTask(fileSystem, environment);
            compiler.Output = new Path("Build").Combine("Bar.dll");
            compiler.References.Add(new Path("Foo.dll"));

            fileSystem.DirectoryExistsHandler = x => true;
            fileSystem.FileExistsHandler = x => true;
            fileSystem.CopyFileHandler = (from, to, overwrite) =>
            {
                Assert.Fail("Should not try to copy file already present.");
            };
            compiler.Execute();
        }
예제 #4
0
        public void Should_copy_referenced_assemblies()
        {
            var fileSystem = new FileSystemStub();
            var environment = new ExecutionEnvironmentStub();

            var compiler = new CSharpCompilerTask(fileSystem, environment);
            var outDir = new Path("Build");
            compiler.Output = outDir.Combine("Bar.dll");
            compiler.References.Add(new Path("Foo.dll"));

            fileSystem.DirectoryExistsHandler = x => true;
            fileSystem.FileExistsHandler = x => x.Equals(new Path("Foo.dll"));
            bool copied = false;
            fileSystem.CopyFileHandler = (from, to, overwrite) =>
            {
                Assert.AreEqual(new Path("Foo.dll"), from);
                Assert.AreEqual(outDir + "Foo.dll", to);
                copied = true;
            };
            compiler.Execute();

            Assert.IsTrue(copied, "Referenced assembly not copied.");
        }