public void Listing5_01to06()
 {
     using (ConsoleTester consoleTester = ConsoleTester.GetConsoleTester(
                "<<Inigo Montoya: Enough to survive on\r\n"))
     {
         Program_Accessor.Main();
     }
 }
Esempio n. 2
0
        public void LaunchAndDoNothing()
        {
            ConsoleTester tester = new ConsoleTester("MbUnit.Gui.exe", "/close");

            tester.ExpectedExitCode = 100;
            tester.Run();
            System.Threading.Thread.Sleep(1000);
        }
Esempio n. 3
0
 public void RunTestsWithGui()
 {
     ConsoleTester runner = new ConsoleTester(
         "MbUnit.Gui.exe",
         Path.Combine(directory, "ParentAssembly.dll"),
         "/run",
         "/close"
         );
 }
Esempio n. 4
0
        public void RunTestsWithConsole()
        {
            ConsoleTester runner = new ConsoleTester(
                "MbUnit.Cons.exe",
                Path.Combine(directory, "ParentAssembly.dll")
                );

            runner.Run();
        }
Esempio n. 5
0
        public void SimpleProject()
        {
            // load project file
            ConsoleTester tester = new ConsoleTester(
                this.msbuildPath,
                @"Tasks\MSBuild\msbuild.sample1.xml"
                );

            tester.Run();
        }
Esempio n. 6
0
        public void MultipleSetOfAssemblies()
        {
            // load project file
            ConsoleTester tester = new ConsoleTester(
                this.nantPath,
                "-buildfile:Tasks/NAnt/nant.sample3.xml",
                "tests"
                );

            tester.Run();
        }
Esempio n. 7
0
        public void DifferentReports()
        {
            // load project file
            ConsoleTester tester = new ConsoleTester(
                this.nantPath,
                "-buildfile:Tasks/NAnt/nant.sample2.xml",
                "tests"
                );

            tester.Run();
        }
Esempio n. 8
0
        public void SimpleProject()
        {
            // load project file
            ConsoleTester tester = new ConsoleTester(
                this.nantPath,
                "-buildfile:Tasks/NAnt/nant.sample.xml",
                "tests"
                );

            tester.Run();
        }
Esempio n. 9
0
        //   [Test]
        public void LaunchRunProjectCloseGui()
        {
            ConsoleTester tester = new ConsoleTester(
                "MbUnit.Gui.exe",
                "/run",
                @"Gui\demo.mbunit",
                "/close");

            tester.ExpectedExitCode = 100;
            tester.Run();
            System.Threading.Thread.Sleep(1000);
        }
Esempio n. 10
0
        public void LaunchRunParentAssenblyAndCloseGui()
        {
            ConsoleTester tester = new ConsoleTester(
                "MbUnit.Gui.exe",
                "/run",
                "ParentAssembly.dll",
                "/close");

            tester.ExpectedExitCode = 100;
            tester.Run();
            System.Threading.Thread.Sleep(1000);
        }
        public void RootDirectoryWithoutTrailingSlash()
        {
            string root        = @".\Blah\";
            string chapter     = "5";
            string fromListing = "15-29";
            string toListing   = "30-31";

            using (ConsoleTester tester = ConsoleTester.GetConsoleTester(
                       string.Format("<<{0}\r\n", Program.HelpText) +
                       string.Format(@"<>The chapter folder, ""{0}\Blah\Chapter05\Listing5_30-31"", could not be found." + Environment.NewLine,
                                     Environment.CurrentDirectory)))
            {
                Assert.AreEqual <int>(-1, Program.Main(root, chapter, fromListing, toListing));
            }
        }
        public void ChapterDirectoryDoesNotExist()
        {
            string root        = @".\MockProject\";
            string chapter     = "99";
            string fromListing = "15-29";
            string toListing   = "30-31";

            using (ConsoleTester tester = ConsoleTester.GetConsoleTester(
                       string.Format("<<{0}\r\n", Program.HelpText) +
                       string.Format(@"<>The chapter folder, ""{0}\MockProject\Chapter99\Listing99_30-31"", could not be found." + Environment.NewLine,
                                     Environment.CurrentDirectory)))
            {
                Assert.AreEqual <int>(-1, Program.Main(root, chapter, fromListing, toListing));
            }
        }
        public void MainTest2()
        {
            string root        = @".\MockProject\";
            string chapter     = "5";
            string fromListing = "15-29";
            string toListing   = "98-99";

            string fromName        = string.Format("Listing{0}_{1}", chapter, fromListing);
            string toName          = string.Format("Listing{0}_{1}", chapter, toListing);
            string chapterFolder   = "Chapter" + chapter.PadLeft(2, '0');
            string fromProjectName = string.Format("{0}.Listing{1}_{2}", chapterFolder, chapter, fromListing);
            string toProjectName   = string.Format("{0}.Listing{1}_{2}", chapterFolder, chapter, toListing);

            ConsoleTester tester = ConsoleTester.GetConsoleTester();

            tester.Execute(".\\ProjectRename.exe", string.Format("{0} {1} {2} {3}", root, chapter, fromListing, toListing));

            DirectoryInfo fromProjectDirectory = new DirectoryInfo(PathEx.Combine(root, chapterFolder, fromName));

            Assert.IsTrue(fromProjectDirectory.Exists, "From project directory does not exists.  Problem with the test.");

            DirectoryInfo toProjectDirectory = new DirectoryInfo(PathEx.Combine(root, chapterFolder, toName));

            Assert.IsTrue(fromProjectDirectory.Exists, "to directory was not even created");

            foreach (FileInfo file in toProjectDirectory.GetFiles("*", SearchOption.AllDirectories))
            {
                if (file.Directory.Parent.Name.ToLower() != "bin" && file.Directory.Parent.Name.ToLower() != "obj")
                {
                    TestContext.WriteLine(file.Name);
                    Assert.IsFalse(file.Name.Contains(fromName));
                    using (StreamReader reader = new StreamReader(file.FullName))
                    {
                        string content = reader.ReadToEnd();
                        Assert.IsFalse(content.Contains(fromName));
                        Assert.IsFalse(content.Contains(fromName.Replace("-", "to")));
                    }
                }
            }
        }
Esempio n. 14
0
        public void Execute()
        {
            ConsoleTester.ClearAndStartCapturing();

            DynamicMethodGen dmg = DynamicMethodGen.Static(typeof(DynamicMethodTest)).Method(typeof(string), new TypeMapper())
                                   .Parameter(typeof(string), "name")
                                   .Parameter(typeof(string), "other");
            CodeGen g = dmg.GetCode();
            {
                g.Try();
                {
                    var name = g.Local(typeof(string), g.Arg("name"));
                    g.WriteLine("Hello " + name + "!");
                }
                g.CatchAll();
                {
                    g.WriteLine("Error");
                }
                g.End();
                g.Return(dmg.StaticFactory.Invoke(typeof(DynamicMethodTest), nameof(CallMe), g.Arg("other"), 2));
            }
            DynamicMethod dm = dmg.GetCompletedDynamicMethod(true);


            // reflection-style invocation
            Assert.That(dm.Invoke(null, new object[] { "Dynamic Method", "first1" }), Is.EqualTo("test240"));

            // delegate invocation
            Func <string, string, string> hello = (Func <string, string, string>)dm.CreateDelegate(typeof(Func <string, string, string>));

            Assert.That(hello("Delegate", "first1"), Is.EqualTo("test240"));

            ConsoleTester.AssertAndClear(@"Hello Dynamic Method!
Hello Delegate!
");
        }
Esempio n. 15
0
 public void Setup()
 {
     ConsoleTester.Initialize();
 }
Esempio n. 16
0
 static void Main(string[] args)
 {
     ConsoleTester.RunAndPrintTests();
 }