Ejemplo n.º 1
0
        public void TestMethod1()
        {
            VsTestParser            parser      = new VsTestParser();
            IList <VsTestClassInfo> testClasses = parser.Parse(@"H:\AspNetDeploy\Variables.Tests\bin\Debug\Variables.Tests.dll");

            foreach (VsTestClassInfo testClass in testClasses)
            {
                VsTestRunner runner = new VsTestRunner();

                Console.WriteLine(testClass.Type.FullName);

                foreach (string testMethod in testClass.TestMethods)
                {
                    VsTestRunResult vsTestRunResult = runner.Run(testClass.Type, testClass.InitializeMethod, testMethod, testClass.CleanupMethod);
                    Console.WriteLine((vsTestRunResult.IsSuccess ? "PASS" : "FAIL") + " - " + testMethod + " - " + vsTestRunResult.Exception?.Message);
                }
            }
        }
        public IList <TestResult> Run(ProjectVersion projectVersion)
        {
            string sourcesFolder = this.pathServices.GetSourceControlVersionPath(projectVersion.SourceControlVersion.SourceControlId, projectVersion.SourceControlVersion.Id);
            string projectPath   = Path.Combine(sourcesFolder, projectVersion.ProjectFile);

            XDocument xDocument = XDocument.Load(projectPath);

            string outputPath   = this.GetProperty(xDocument, "OutputPath");
            string assemblyName = this.GetProperty(xDocument, "AssemblyName");

            VsTestParser            parser      = new VsTestParser();
            IList <VsTestClassInfo> testClasses = parser.Parse(Path.Combine(Path.GetDirectoryName(projectPath), outputPath, assemblyName + ".dll"));

            IList <TestResult> result = new List <TestResult>();

            foreach (VsTestClassInfo testClass in testClasses)
            {
                VsTestRunner runner = new VsTestRunner();

                Parallel.ForEach(
                    testClass.TestMethods,
                    new ParallelOptions
                {
                    MaxDegreeOfParallelism = 4
                },
                    testMethod =>
                {
                    VsTestRunResult vsTestRunResult = runner.Run(testClass.Type, testClass.InitializeMethod, testMethod, testClass.CleanupMethod, variableProcessor.ProcessValue);

                    result.Add(new TestResult()
                    {
                        TestClassName = testClass.Type.FullName,
                        TestName      = testMethod,
                        IsPass        = vsTestRunResult.IsSuccess,
                        Message       = vsTestRunResult.Exception?.Message + ". " + vsTestRunResult.Exception?.InnerException?.Message
                    });
                });
            }

            return(result);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            XDocument webConfig = XDocument.Load(@"H:\Documentoved\FiasOnline\FiasOnline.UI.API\bin\Release\netcoreapp2.0\publish\web.config");

            if (webConfig.Descendants("aspNetCore").Any(dd => dd.Attribute("processPath")?.Value == "dotnet"))
            {
            }

            using (ServerManager serverManager = new ServerManager())
            {
                //this.backupSiteConfigurationGuid = this.BackupRepository.StoreObject(site);

                ApplicationPool applicationPool  = ApplicationPool(serverManager, "AspNetDeploy");
                ApplicationPool applicationPool2 = ApplicationPool(serverManager, "ButtonBackend1");
            }



            VisualStudio2013SolutionParser      solutionParser = new VisualStudio2013SolutionParser();
            IList <VisualStudioSolutionProject> projects       = solutionParser.Parse(@"H:\Documentoved\FiasOnline\FiasOnline.sln");

            foreach (VisualStudioSolutionProject project in projects)
            {
                Console.WriteLine(project.Name + " - " + project.Type + " - " + project.Guid + " - " + project.TypeGuid);
            }

            DotnetCoreBuildService buildService = new DotnetCoreBuildService();

            ProjectVersion pv = new ProjectVersion()
            {
                Name         = "Blah",
                ProjectType  = ProjectType.Web | ProjectType.NetCore,
                ProjectFile  = @"FiasOnline.UI.API\FiasOnline.UI.API.csproj",
                SolutionFile = @"H:\Documentoved\FiasOnline"
            };

            buildService.Build(@"H:\Documentoved\FiasOnline", pv, s =>
            {
            }, (s, b, arg3) =>
            {
            }, (s, exception) =>
            {
            });

            if (File.Exists(@"H:\Documentoved\FiasOnline\blah.zip"))
            {
                File.Delete(@"H:\Documentoved\FiasOnline\blah.zip");
            }

            DotNetCoreProjectPackager projectPackager = new DotNetCoreProjectPackager();

            projectPackager.Package(@"H:\Documentoved\FiasOnline\FiasOnline.UI.API\FiasOnline.UI.API.csproj", @"H:\Documentoved\FiasOnline\blah.zip");

            Console.WriteLine(projects.Count);



            //ThreadTaskRunner.ProcessTasks();

            /*
             * VariableProcessorFactory variableProcessorFactory = new VariableProcessorFactory();
             * ProjectTestRunnerFactory projectTestRunnerFactory = new ProjectTestRunnerFactory(new PathServices());
             *
             * IVariableProcessor variableProcessor = variableProcessorFactory.Create(278, 9);
             *
             * AspNetDeployEntities entities = new AspNetDeployEntities();
             * ProjectVersion projectVersion2 = entities.ProjectVersion.Include("SourceControlVersion").First( v => v.Id == 14746);
             *
             *
             * IProjectTestRunner projectTestRunner = projectTestRunnerFactory.Create(projectVersion2.ProjectType, variableProcessor);
             *
             * IList<TestResult> testResults = projectTestRunner.Run(projectVersion2);
             *
             */

            VsTestParser            parser      = new VsTestParser();
            IList <VsTestClassInfo> testClasses = parser.Parse(@"H:\Documentoved\DocumentovedUITests\AccountTests\bin\Debug\AccountTests.dll");

            IList <TestResult> result = new List <TestResult>();

            IDictionary <string, string> d = new ConcurrentDictionary <string, string>();

            string c = null;

            Thread t = new Thread(() =>
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine(c);
                    foreach (string dKey in d.Keys)
                    {
                        Console.WriteLine(" - " + dKey + " - " + d[dKey]);
                    }

                    Thread.Sleep(1000);
                }
            });

            t.Start();

            foreach (VsTestClassInfo testClass in testClasses)
            {
                c = testClass.Type.FullName;
                d.Clear();

                Parallel.ForEach(testClass.TestMethods, new ParallelOptions
                {
                    MaxDegreeOfParallelism = 5
                }, testMethod =>
                {
                    d.Add(testMethod, "started");

                    VsTestRunner runner             = new VsTestRunner();
                    VsTestRunResult vsTestRunResult = runner.Run(testClass.Type, testClass.InitializeMethod, testMethod, testClass.CleanupMethod);

                    result.Add(new TestResult()
                    {
                        TestClassName = testClass.Type.FullName,
                        TestName      = testMethod,
                        IsPass        = vsTestRunResult.IsSuccess,
                        Message       = vsTestRunResult.Exception?.Message + ". " + vsTestRunResult.Exception?.InnerException?.Message
                    });

                    d[testMethod] = vsTestRunResult.IsSuccess ? "done" : "fail";
                });
            }



            Console.WriteLine("DONE");
            Console.ReadKey();


            /*
             * GulpParser gulpParser = new GulpParser(@"H:\Documentoved\Resources");
             *
             * gulpParser.LoadProjects();
             *
             * GulpProjectPackager gulpProjectPackager = new GulpProjectPackager();
             *
             * gulpProjectPackager.Package(@"H:\Documentoved\Resources\documentoved.gulpfile.js", @"H:\Documentoved\Resources\result.zip");
             *
             *
             * return;
             */
            /*
             * dynamic bindingConfig = JsonConvert.DeserializeObject("{ port:80, host:'abc.local'}");
             *
             * using (ServerManager serverManager = new ServerManager())
             * {
             *  Site site = serverManager.Sites["Account Service Latest"];
             *
             *  foreach (Binding siteBinding in site.Bindings)
             *  {
             *      siteBinding.BindingInformation = (string.IsNullOrWhiteSpace((string)bindingConfig.IP) ? "" : (string)bindingConfig.IP) + ":" + (int)bindingConfig.port + ":" + (string)bindingConfig.host;
             *  }
             *
             *  serverManager.CommitChanges();
             * }
             *
             * return;
             */


            /*
             *
             *          Machine machine = entities.Machine.First( m => m.Name == "Lake");
             *
             *          WCFSatelliteDeploymentAgent agent = new WCFSatelliteDeploymentAgent(null, machine.URL, machine.Login, machine.Password, new TimeSpan(0, 0, 0, 1), new TimeSpan(0, 0, 0, 1));
             *
             *          Console.WriteLine("Runnning");
             *          Console.WriteLine(agent.IsReady());
             */

            /*
             *
             *           List<Machine> machines = entities.Machine.ToList();
             *
             *           machines.Where( m => !m.Name.Contains("FastVPS") && !m.Name.Contains("Snow")).ToList().AsParallel().ForAll(machine =>
             *           {
             *               WCFSatelliteDeploymentAgent deploymentAgent = new WCFSatelliteDeploymentAgent(null, machine.URL, machine.Login, machine.Password, new TimeSpan(0, 0, 1));
             *               Console.WriteLine(machine.Id + " - " + machine.Name + " - " + deploymentAgent.IsReady());
             *           });
             *
             *          Console.WriteLine("-=====================-");
             *
             *          ISatelliteMonitor satelliteMonitor = new SatelliteMonitor();
             *
             *          List<Environment> environments = entities.Environment
             *              .Include("Properties")
             *              .Include("Machines.MachineRoles")
             *              .ToList();
             *
             *          Dictionary<Machine, SatelliteState> dictionary = environments.SelectMany(e => e.Machines)
             *              .Distinct()
             *              .AsParallel()
             *              .Select(m => new { m, alive = satelliteMonitor.IsAlive(m) })
             *              .ToDictionary(k => k.m, k => k.alive);
             *
             *          DateTime start = DateTime.Now;
             *
             *          Dictionary<Machine, IServerSummary> summaries = environments.SelectMany(e => e.Machines)
             *              .Distinct()
             *              .AsParallel()
             *              .Select(m => new { m, summary = satelliteMonitor.GetServerSummary(m) })
             *              .ToDictionary(k => k.m, k => k.summary);
             *
             *          DateTime end = DateTime.Now;
             *
             *          Console.WriteLine((end-start).TotalSeconds);
             *
             *          foreach (KeyValuePair<Machine, SatelliteState> serverSummary in dictionary)
             *          {
             *              Console.WriteLine(serverSummary.Key + " - " + serverSummary.Value);
             *          }
             */


            MSBuildBuildService buildBuildService = new MSBuildBuildService(new PathServices());

            DateTime?startDate = null;

            ProjectVersion projectVersion = new ProjectVersion()
            {
                // ProjectFile = @"ZelbikeRace2Database\ZelbikeRace2Database.sqlproj",
                ProjectFile  = @"Services.Accounts\Services.Accounts.csproj",
                SolutionFile = @"Documentoved.sln"
            };

            Console.WriteLine("Starting");

            BuildSolutionResult buildSolutionResult = buildBuildService.Build(@"C:\AspNetDeployWorkingFolderO\Sources\5\207", projectVersion,
                                                                              s =>
            {
                if (startDate == null)
                {
                    startDate = DateTime.Now;
                }

                Console.WriteLine(s + " - started");
            },
                                                                              (s, b, arg3) =>
            {
                Console.WriteLine(s + " - " + b);
            },
                                                                              (s, s1) =>
            {
                // e.ProjectFile, e.File, e.Code, e.LineNumber, e.ColumnNumber, e.Message
                Console.WriteLine(s + "\n" + s1);
                Console.WriteLine(s1.Message + "\n" + s1);
            });

            DateTime endDate = DateTime.Now;

            Console.WriteLine(buildSolutionResult.IsSuccess);
            Console.WriteLine((endDate - startDate.Value).TotalMilliseconds);



            /*
             * //string path = @"H:\Documentoved\Latest\Services.ImsPrimary\Databases.ImsPrimary.sqlproj";
             * string path = @"H:\Documentoved\Latest\Services.ExceptionHandlingService\Services.Logging.csproj";
             *
             * //  SolutionFile solutionFile = SolutionFile.Parse(path);
             *
             * // ProjectRootElement element = ProjectRootElement.Open(@"H:\Documentoved\Latest\Services.ExceptionHandlingService\Services.Logging.csproj");
             *
             *
             * Dictionary<string, string> globalProperty = new Dictionary<string, string>
             * {
             *  {"Configuration", "Release"}
             * };
             *
             * ProjectCollection projectCollection = new ProjectCollection();
             *
             * BuildRequestData buildRequestData = new BuildRequestData(path, globalProperty, "14.0", new[] { "Rebuild" }, null);
             *
             * BuildParameters buildParameters = new BuildParameters(projectCollection);
             * buildParameters.MaxNodeCount = 1;
             * buildParameters.Loggers = new List<ILogger>
             * {
             *  new ConsoleLogger()
             * };
             *
             *
             *
             *
             * BuildResult buildResult = Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(buildParameters, buildRequestData);
             *
             */

            //Console.WriteLine("building " + buildResult.OverallResult);

            /*
             *
             *          ObjectFactoryConfigurator.Configure();
             *
             *          Console.WriteLine("Testing satellites");
             *
             *          AspNetDeployEntities entities = new AspNetDeployEntities();
             *
             *          MSBuildBuildService service = new MSBuildBuildService(new NugetPackageManager(new PathServices()));
             *          service.Build(
             *              @"H:\AspNetDeployWorkingFolder\Sources\5\45\CodeBase.Documents.WebUI\CodeBase.Documents.WebUI.csproj",
             *              s => Console.WriteLine("started: " + s), (s, b, arg3) => Console.WriteLine("done: " + arg3), (s, s1, arg3, arg4, arg5, arg6) => Console.WriteLine("Err: " + s));*/

            /*foreach (Machine machine in entities.Machine)
             * {
             *  Console.Write(machine.Name + "...");
             *  Console.WriteLine(Factory.GetInstance<ISatelliteMonitor>().IsAlive(machine));
             * }
             *
             * Console.ReadKey();
             *
             * RunScheduler();*/

            WriteLine("Main thread complete");
            Console.ReadKey();
        }