Esempio n. 1
0
        public void Setup()
        {
            fileSystem = new InMemoryFileSystem();
            environment = new ExecutionEnvironmentStub();

            compiler = new CSharpCompilerTask(fileSystem, environment);
        }
Esempio n. 2
0
        public void Should_use_mono_for_program_if_running_on_mono()
        {
            var envionrment = new ExecutionEnvironmentStub();
            envionrment.IsMonoHandler = () => true;
            var nunit = new NUnitTask(envionrment);

            nunit.Program.ShouldEqual(new Path("mono"));
        }
Esempio n. 3
0
 public void Should_support_disabling_shadow_copy()
 {
     var fileSystem = new InMemoryFileSystem();
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(fileSystem, environment) {ShadowCopy = false};
     environment.RunHandler += (p, args, x) => args.Contains("-noshadow").ShouldBe(true);
     nunit.Run();
 }
Esempio n. 4
0
        public void Should_use_mono_for_program_if_running_on_mono()
        {
            var fileSystem = new InMemoryFileSystem();
            var envionrment = new ExecutionEnvironmentStub {IsMonoHandler = () => true};
            var nunit = new NUnitTask(fileSystem, envionrment);

            nunit.Program.ShouldEqual(new Path("mono"));
        }
Esempio n. 5
0
        public void Should_use_nunit_console_for_program_if_not_on_mono()
        {
            var fileSystem = new InMemoryFileSystem();
            var envionrment = new ExecutionEnvironmentStub {IsMonoHandler = () => false};
            var nunit = new NUnitTask(fileSystem, envionrment);

            nunit.Program.ToString().EndsWith("nunit-console.exe").ShouldBe(true);
        }
Esempio n. 6
0
 public void Arguments_should_contain_Target()
 {
     var fileSystem = new InMemoryFileSystem();
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(fileSystem, environment) {Target = new Path("MyTests.dll")};
     environment.RunHandler += (p, args, x) => args.Contains("MyTests.dll").ShouldBe(true);
     nunit.Run();
 }
Esempio n. 7
0
 public void NUnitPath_should_be_based_on_NUnitBinPath()
 {
     var envionrment = new ExecutionEnvironmentStub();
     envionrment.IsMonoHandler = () => false;
     var nunit = new NUnitTask(envionrment);
     var binPath = new Path("NUnit") + "bin";
     nunit.NUnitBinPath = binPath;
     nunit.NUnitPath.ShouldEqual(binPath + "nunit-console.exe");
 }
Esempio n. 8
0
        public void Arguments_should_start_with_NUnitPath_on_mono()
        {
            var fileSystem = new InMemoryFileSystem();
            var environment = new ExecutionEnvironmentStub {IsMonoHandler = () => true};
            var nunit = new NUnitTask(fileSystem, environment);

            environment.RunHandler += (p, args, x) => args.StartsWith(nunit.NUnitPath.ToString()).ShouldBe(true);
            nunit.Run();
        }
Esempio n. 9
0
 public void NUnitPath_should_be_based_on_NUnitBinPath()
 {
     var fileSystem = new InMemoryFileSystem();
     var envionrment = new ExecutionEnvironmentStub {IsMonoHandler = () => false};
     var nunit = new NUnitTask(fileSystem, envionrment);
     var binPath = new Path("NUnit").Combine("bin");
     nunit.NUnitBinPath = binPath;
     nunit.NUnitPath.ShouldEqual(binPath.Combine("nunit-console.exe"));
 }
Esempio n. 10
0
 public void Should_support_disabling_logo()
 {
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(environment);
     nunit.ShowLogo = false;
     environment.RunHandler = (p, args, x) =>
     {
         args.Contains("-nologo").ShouldBe(true);
     };
     nunit.Execute();
 }
Esempio n. 11
0
 public void Should_support_disabling_shadow_copy()
 {
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(environment);
     nunit.ShadowCopy = false;
     environment.RunHandler += (p, args, x) =>
     {
         args.Contains("-noshadow").ShouldBe(true);
     };
     nunit.Execute();
 }
Esempio n. 12
0
 public void Should_support_disabling_logo()
 {
     var fileSystem = new InMemoryFileSystem();
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(fileSystem, environment) {ShowLogo = false};
     environment.RunHandler = (p, args, x) =>
     {
         args.Contains("-nologo").ShouldBe(true);
     };
     nunit.Run();
 }
Esempio n. 13
0
 public void Arguments_should_contain_Target()
 {
     var environment = new ExecutionEnvironmentStub();
     var nunit = new NUnitTask(environment);
     nunit.Target = new Path("MyTests.dll");
     environment.RunHandler += (p, args, x) =>
     {
         args.Contains("MyTests.dll").ShouldBe(true);
     };
     nunit.Execute();
 }
Esempio n. 14
0
        public void Arguments_should_start_with_NUnitPath_on_mono()
        {
            var environment = new ExecutionEnvironmentStub();
            environment.IsMonoHandler = () => true;
            var nunit = new NUnitTask(environment);

            environment.RunHandler += (p, args, x) =>
            {
                args.StartsWith(nunit.NUnitPath.ToString()).ShouldBe(true);
            };
            nunit.Execute();
        }
Esempio n. 15
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();
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
 public void Execute_should_call_wait_for_exit_before_ExitCode()
 {
     //Since mono is broken and won't give us the ExitCode otherwise.
     var process = new ProcessStub();
     var waitForExitCalled = false;
     process.WaitForExitHandler = () => waitForExitCalled = true;
     process.GetExitCodeHandler = () =>
     {
         Assert.IsTrue(waitForExitCalled);
         return 0;
     };
     var platform = new ExecutionEnvironmentStub();
     platform.RunHandler = (program, args, handler) => handler(process);
     var task = new TestTask(platform);
     task.Execute();
 }
Esempio n. 18
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();
        }
Esempio n. 19
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.");
        }
Esempio n. 20
0
        public void Should_use_nunit_console_for_program_if_not_on_mono()
        {
            var envionrment = new ExecutionEnvironmentStub();
            envionrment.IsMonoHandler = () => false;
            var nunit = new NUnitTask(envionrment);

            nunit.Program.ToString().EndsWith("nunit-console.exe").ShouldBe(true);
        }