Write() public method

public Write ( char data ) : void
data char
return void
Beispiel #1
0
        private static int RunInstallPackage(PackageOptions options)
        {
            console.Write("Downloading catalogs...");

            var availablePackages = new List <PackageReference>();

            foreach (var packageSource in PackageSources.Instance.Sources)
            {
                RepositoryOld repo = null;

                var awaiter = packageSource.DownloadCatalog();

                awaiter.Wait();

                repo = awaiter.Result;

                console.WriteLine("Done");

                console.WriteLine("Enumerating Packages...");

                if (repo != null)
                {
                    foreach (var packageReference in repo.Packages)
                    {
                        availablePackages.Add(packageReference);
                        console.WriteLine(packageReference.Name);
                    }
                }
            }

            var package = availablePackages.FirstOrDefault(p => p.Name == options.Package);

            if (package != null)
            {
                var task = package.DownloadInfoAsync();
                task.Wait();

                var repo = task.Result;

                var downloadTask = repo.Synchronize(options.Tag, console);
                downloadTask.Wait();

                return(1);
            }
            console.WriteLine("Unable to find package " + options.Package);
            return(-1);
        }
Beispiel #2
0
        private static int RunTest(TestOptions options)
        {
            var result   = 1;
            var solution = LoadSolution(options);

            solution.LoadSolutionAsync().Wait();
            solution.LoadProjectsAsync().Wait();

            var tests = new List <Test>();

            foreach (var project in solution.Projects)
            {
                if (project.TestFramework != null)
                {
                    var buildTask = project.ToolChain.BuildAsync(console, project, "");

                    buildTask.Wait();

                    if (buildTask.Result)
                    {
                        var awaiter = project.TestFramework.EnumerateTestsAsync(project);
                        awaiter.Wait();

                        foreach (var test in awaiter.Result)
                        {
                            tests.Add(test);
                        }
                    }
                    else
                    {
                        result = 2;
                    }
                }
            }

            foreach (var test in tests)
            {
                test.Run();

                if (test.Pass)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    console.Write("\x1b[32;1m");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    console.Write("\x1b[31;1m");
                }

                console.WriteLine(string.Format("Running Test: [{0}], [{1}]", test.Name, test.Pass ? "Passed" : "Failed"));

                if (!test.Pass)
                {
                    console.WriteLine();
                    console.WriteLine(string.Format("Assertion = [{0}], File=[{1}], Line=[{2}]", test.Assertion, test.File, test.Line));
                    console.WriteLine();
                }

                Console.ForegroundColor = ConsoleColor.White;
                console.Write("\x1b[39; 49m");

                if (!test.Pass)
                {
                    result = 0;
                }
            }

            return(result);
        }