Exemple #1
0
        public void Test()
        {
            var gen = new XmlResultsGenerator(null, null, null, null, null);

            var muSession = new MutationTestingSession();

            var mutar = new MutationTarget(new MutationVariant());


            var ass = new AssemblyNode("Assembly");

            muSession.MutantsGrouped.Add(ass);
            var nodeNamespace = new TypeNamespaceNode(ass, "Namespace");

            ass.Children.Add(nodeNamespace);
            var nodeType = new TypeNode(nodeNamespace, "Type");

            nodeNamespace.Children.Add(nodeType);
            var nodeMethod = new MethodNode(nodeType, "Method", null, true);

            nodeType.Children.Add(nodeMethod);
            var nodeGroup = new MutantGroup("Gr1", nodeMethod);

            nodeMethod.Children.Add(nodeGroup);
            var nodeMutant = new Mutant("m1", nodeGroup, mutar);

            nodeGroup.Children.Add(nodeMutant);

            XDocument generateResults = gen.GenerateResults(muSession, false, false, ProgressCounter.Inactive(), CancellationToken.None).Result;

            Console.WriteLine(generateResults.ToString());
            //gen.
        }
        public void Test()
        {
             var gen = new XmlResultsGenerator(null,null,null, null, null);

            var muSession = new MutationTestingSession();
            
            var mutar = new MutationTarget(new MutationVariant());


            var ass = new AssemblyNode("Assembly");
            muSession.MutantsGrouped.Add(ass);
            var nodeNamespace = new TypeNamespaceNode(ass, "Namespace");
            ass.Children.Add(nodeNamespace);
            var nodeType = new TypeNode(nodeNamespace, "Type");
            nodeNamespace.Children.Add(nodeType);
            var nodeMethod = new MethodNode(nodeType, "Method", null, true);
            nodeType.Children.Add(nodeMethod);
            var nodeGroup = new MutantGroup("Gr1", nodeMethod);
            nodeMethod.Children.Add(nodeGroup);
            var nodeMutant = new Mutant("m1", nodeGroup, mutar);
            nodeGroup.Children.Add(nodeMutant);

            XDocument generateResults = gen.GenerateResults(muSession, false, false, ProgressCounter.Inactive(), CancellationToken.None).Result;

            Console.WriteLine(generateResults.ToString());
            //gen.
        }
        public async Task SaveResults(string path = null)
        {
            if (path == null)
            {
                if (string.IsNullOrEmpty(_viewModel.TargetPath) ||
                    !Path.IsPathRooted(_viewModel.TargetPath))
                {
                    _svc.Logging.ShowError("Invalid path");
                    return;
                }
                path = _viewModel.TargetPath;
            }

            _viewModel.SavingInProgress = true;
            _cts = new CancellationTokenSource();
            var progress = ProgressCounter.Invoking(i => _viewModel.Progress = i);

            XDocument document = await _generator.GenerateResults(_currentSession,
                                                                  _viewModel.IncludeDetailedTestResults,
                                                                  _viewModel.IncludeCodeDifferenceListings,
                                                                  progress,
                                                                  _cts.Token);

            try
            {
                using (var writer = _fs.File.CreateText(path))
                {
                    writer.Write(document.ToString());
                }
                _svc.Settings["MutationResultsFilePath"] = path;

                _viewModel.Close();


                var p = new Process();

                p.StartInfo.FileName = path;
                p.Start();
            }
            catch (IOException)
            {
                _svc.Logging.ShowError("Cannot write file: " + path);
            }
        }