private void SetupDataSingleModule()
        {
            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 0);
            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 1, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 1, Path = 1, Ordinal = 2
            });

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Tests.CoverageSummaryTests::TestCalculateSummary()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Tests.CoverageSummaryTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            _averageCalculationSingleModule = new Modules();
            _averageCalculationSingleModule.Add("module", documents);
        }
Example #2
0
        private static Documents CreateFirstDocuments()
        {
            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 0);

            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 0, Offset = 23, EndOffset = 27, Path = 1, Ordinal = 2
            });

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Reporters.Tests.OpenCoverReporterTests.TestReport()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.OpenCoverReporterTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            return(documents);
        }
Example #3
0
        public CoverageResultTests()
        {
            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 1);
            lines.Add(3, 1);
            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 1, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 1, Path = 1, Ordinal = 2
            });
            branches.Add(new BranchInfo {
                Line = 2, Hits = 0, Offset = 1, Path = 0, Ordinal = 1
            });

            // System.Void Coverlet.Core.Tests.CoverageResultTests::CoverageResultTests - 3/3 100% line 2/3 66.7% branch coverage
            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Tests.CoverageResultTests::CoverageResultTests()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            // System.Void Coverlet.Core.Tests.CoverageResultTests::GetThresholdTypesBelowThreshold - 0/2 0% line
            methodString = "System.Void Coverlet.Core.Tests.CoverageResultTests::GetThresholdTypesBelowThreshold()";
            methods.Add(methodString, new Method());
            methods[methodString].Lines = new Lines()
            {
                { 1, 0 },
                { 2, 0 },
            };

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Tests.CoverageResultTests", methods);
            // Methods  - 1/2 (50%)
            // Lines    - 3/5 (60%)
            // Branches - 2/3 (66.67%)

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            _modules = new Modules();
            _modules.Add("module", documents);
        }
Example #4
0
        public void AttachBranch(IWorkflowBuilder branch)
        {
            if (Branches.Contains(branch))
            {
                return;
            }

            foreach (var step in branch.Steps)
            {
                var oldId = step.Id;
                AddStep(step);
                foreach (var step2 in branch.Steps)
                {
                    foreach (var outcome in step2.Outcomes)
                    {
                        if (outcome.NextStep == oldId)
                        {
                            outcome.NextStep = step.Id;
                        }
                    }
                }
            }

            Branches.Add(branch);
        }
 private void AddImpl(Element item)
 {
     if (item is Branch)
     {
         var branch = (Branch)item;
         if (!branch.IsInternal())
         {
             Branches.Add(branch);
         }
         else
         {
             InternalBranches.Add(branch);
         }
     }
     else if (item is Value)
     {
         var value = (Value)item;
         if (!value.IsInternal())
         {
             Values.Add(value);
         }
         else
         {
             InternalValues.Add(value);
         }
     }
     else
     {
         throw new NotSupportedException(String.Format("Abstract nodes of type '{0}' are not supported.",
                                                       item == null ? "null" : item.GetType().FullName));
     }
 }
Example #6
0
        public void AddBranch(K key, V value)
        {
            var branch = new DictionaryTree <K, V>(key, value);

            branch._Root = this;
            Branches.Add(key, branch);
        }
Example #7
0
        /// <summary>
        /// Interpret the Refs section into individual elements
        /// </summary>
        /// <param name="refArg"></param>
        private void ProcessRefs(string refArg)
        {
            // Convert the last field in output into multiple fields
            int first = refArg.IndexOf('(');

            ControlFlow.Assert(first > -1, "Unable to locate the property results starting character - (");
            int last = refArg.IndexOf(')');

            ControlFlow.Assert(last > -1, "Unable to locate the property results ending character - )");
            string props = refArg.Substring(++first, last - first);

            string[] properties = props.Split(',');


            // Now loop thru the properties for common elements that we further split out.
            foreach (string property in properties)
            {
                string propStr = property.Trim();
                if (propStr.StartsWith("tag:"))
                {
                    Tags.Add(propStr.Substring(5));
                }
                else
                {
                    Branches.Add(propStr);
                }
            }
        }
 public void updateBranchCommand(object obj)
 {
     if (branchDB.updateBranch(Branches_id, LisenceNum, FileNum, CompanyName, BranchName, ContractNumber,
                               ReferenceNumber, AutomatedNumber, Area, block, street,
                               phone, Governate, BusinessField, CivilNumber))
     {
         var found = Branches.FirstOrDefault(x => x.Branches_id == Branches_id);
         Branches.Remove(found);
         Branches.Add(new Models.BranchesModel
         {
             LisenceNum      = LisenceNum,
             FileNum         = FileNum,
             CompanyName     = CompanyName,
             BranchName      = BranchName,
             ContractNumber  = ContractNumber,
             ReferenceNumber = ReferenceNumber,
             AutomatedNumber = AutomatedNumber,
             Area            = Area,
             block           = block,
             street          = street,
             phone           = phone,
             Governate       = Governate,
             BusinessField   = BusinessField,
             CivilNumber     = CivilNumber,
         });
     }
 }
 public void addBranchCommand(object obj)
 {
     if (branchDB.addBranches(LisenceNum, FileNum, CompanyName, BranchName, ContractNumber,
                              ReferenceNumber, AutomatedNumber, Area, block, street,
                              phone, Governate, BusinessField, CivilNumber))
     {
         Branches.Add(new Models.BranchesModel
         {
             LisenceNum      = LisenceNum,
             FileNum         = FileNum,
             CompanyName     = CompanyName,
             BranchName      = BranchName,
             ContractNumber  = ContractNumber,
             ReferenceNumber = ReferenceNumber,
             AutomatedNumber = AutomatedNumber,
             Area            = Area,
             block           = block,
             street          = street,
             phone           = phone,
             Governate       = Governate,
             BusinessField   = BusinessField,
             CivilNumber     = CivilNumber,
         });
     }
 }
Example #10
0
        /// <summary>
        /// <para>Pops a value off the stack and branches to the label at the index of that value in the given labels.</para>
        /// <para>If the value is out of range, execution falls through to the next instruction.</para>
        /// </summary>
        public Emit <DelegateType> Switch(params Label[] labels)
        {
            if (labels == null)
            {
                throw new ArgumentNullException("labels");
            }

            if (labels.Length == 0)
            {
                throw new ArgumentException("labels must have at least one element");
            }

            if (LinqAlternative.Any(labels, l => ((IOwned)l).Owner is DisassembledOperations <DelegateType>))
            {
                return
                    (Switch(LinqAlternative.Select(labels, l => l.Name).ToArray()));
            }

            foreach (var label in labels)
            {
                if (((IOwned)label).Owner != this)
                {
                    FailOwnership(label);
                }
            }

            foreach (var label in labels)
            {
                UnusedLabels.Remove(label);
            }

            var transitions =
                new[]
            {
                new StackTransition(new [] { typeof(int) }, TypeHelpers.EmptyTypes),
                new StackTransition(new [] { typeof(NativeIntType) }, TypeHelpers.EmptyTypes),
            };

            var labelsCopy = ((LinqArray <Label>)labels).Select(l => l).ToArray();

            UpdateOpCodeDelegate update;

            UpdateState(OpCodes.Switch, labelsCopy, Wrap(transitions, "Switch"), out update);

            var valid = CurrentVerifiers.ConditionalBranch(labels);

            if (!valid.Success)
            {
                throw new SigilVerificationException("Switch", valid, IL.Instructions(AllLocals));
            }

            foreach (var label in labels)
            {
                Branches.Add(SigilTuple.Create(OpCodes.Switch, label, IL.Index));
                BranchPatches[IL.Index] = SigilTuple.Create(label, update, OpCodes.Switch);
            }

            return(this);
        }
Example #11
0
        public void AttachBranch(IWorkflowBuilder branch)
        {
            if (Branches.Contains(branch))
            {
                return;
            }

            var branchStart = LastStep + branch.LastStep + 1;

            foreach (var step in branch.Steps)
            {
                var oldId = step.Id;
                step.Id = oldId + branchStart;
                foreach (var step2 in branch.Steps)
                {
                    foreach (var outcome in step2.Outcomes)
                    {
                        if (outcome.NextStep == oldId)
                        {
                            outcome.NextStep = step.Id;
                        }
                    }

                    for (var i = 0; i < step2.Children.Count; i++)
                    {
                        if (step2.Children[i] == oldId)
                        {
                            step2.Children[i] = step.Id;
                        }
                    }
                }
            }

            foreach (var step in branch.Steps)
            {
                var oldId = step.Id;
                AddStep(step);
                foreach (var step2 in branch.Steps)
                {
                    foreach (var outcome in step2.Outcomes)
                    {
                        if (outcome.NextStep == oldId)
                        {
                            outcome.NextStep = step.Id;
                        }
                    }

                    for (var i = 0; i < step2.Children.Count; i++)
                    {
                        if (step2.Children[i] == oldId)
                        {
                            step2.Children[i] = step.Id;
                        }
                    }
                }
            }

            Branches.Add(branch);
        }
Example #12
0
 public void AddBranch()
 {
     Model.Branch newlyAddedBranch = new Model.Branch();
     newlyAddedBranch.Name     = this.NewBranchName;
     newlyAddedBranch.Messages = new List <Model.Message>();
     Branches.Add(newlyAddedBranch);
     this.SelectedInteractableObject.Branches.Add(newlyAddedBranch);
 }
Example #13
0
 //Copy Constructor
 public TECScopeBranch(TECScopeBranch scopeBranchSource) : this()
 {
     foreach (TECScopeBranch branch in scopeBranchSource.Branches)
     {
         Branches.Add(new TECScopeBranch(branch));
     }
     _label = scopeBranchSource.Label;
 }
Example #14
0
        public void TestEnsureParseMethodStringCorrectly(
            string methodString,
            string expectedMethodName,
            string expectedSignature)
        {
            var result = new CoverageResult();

            result.Parameters = new CoverageParameters();
            result.Identifier = Guid.NewGuid().ToString();

            var lines = new Lines();

            lines.Add(1, 1);

            var branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });

            var methods = new Methods();

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            var classes = new Classes();

            classes.Add("Google.Protobuf.Reflection.MessageDescriptor", methods);

            var documents = new Documents();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                documents.Add(@"C:\doc.cs", classes);
            }
            else
            {
                documents.Add(@"/doc.cs", classes);
            }

            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            var    reporter = new CoberturaReporter();
            string report   = reporter.Report(result, new Mock <ISourceRootTranslator>().Object);

            Assert.NotEmpty(report);

            var doc         = XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(report)));
            var methodAttrs = doc.Descendants()
                              .Where(o => o.Name.LocalName == "method")
                              .Attributes()
                              .ToDictionary(o => o.Name.LocalName, o => o.Value);

            Assert.Equal(expectedMethodName, methodAttrs["name"]);
            Assert.Equal(expectedSignature, methodAttrs["signature"]);
        }
Example #15
0
        public void TestReport()
        {
            CoverageResult result = new CoverageResult();

            result.Parameters = new CoverageParameters();
            result.Identifier = Guid.NewGuid().ToString();

            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 0);

            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 0, Offset = 23, EndOffset = 27, Path = 1, Ordinal = 2
            });

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Reporters.Tests.LcovReporterTests.TestReport()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.LcovReporterTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);
            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            LcovReporter reporter = new LcovReporter();
            string       report   = reporter.Report(result, new Mock <ISourceRootTranslator>().Object);

            Assert.NotEmpty(report);
            Assert.Equal("SF:doc.cs", report.Split(Environment.NewLine)[0]);
        }
Example #16
0
        private async Task CreateBranchAsync()
        {
            var result = await _gitManager.GitCreateBranchAsync(_repositoryId, _isCheckout, _nameBranch.ToLower()).ConfigureAwait(false);

            Application.Current.Dispatcher.Invoke(delegate
            {
                Branches.Add(result);
            });
            NameBranch = null;
        }
Example #17
0
 public void FillWithRecords(Table table, string columnName)
 {
     foreach (var item in table.AllRecords)
     {
         if (!Branches.Contains(item) && item.Record[columnName].Equals(value))
         {
             Branches.Add(item);
         }
     }
 }
Example #18
0
        //Methods
        public void AddBranch(Chain branch)
        {
            Chain nonReferenceBranch = new Chain();

            foreach (Node n in branch.NodeList)
            {
                nonReferenceBranch.NodeList.Add(n);
            }
            Branches.Add(nonReferenceBranch);
        }
Example #19
0
        public void TestReport()
        {
            CoverageResult result = new CoverageResult();

            result.Identifier = Guid.NewGuid().ToString();

            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 0);

            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 0, Offset = 23, EndOffset = 27, Path = 1, Ordinal = 2
            });

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Reporters.Tests.CoberturaReporterTests::TestReport()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.CoberturaReporterTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            CoberturaReporter reporter = new CoberturaReporter();

            Assert.NotEqual(string.Empty, reporter.Report(result));
        }
 public void AddBranch(IBranch branch)
 {
     if (branch is MercuryBranch)
     {
         Branches.Add(branch);
     }
     else
     {
         Console.WriteLine("Only Mercury Branches can be added to Mercury Repos");
     }
 }
Example #21
0
 public void AddBranch(IBranch branch)
 {
     if (branch is GitBranch)
     {
         Branches.Add(branch);
     }
     else
     {
         Console.WriteLine("Only Git Branches can be added to Git Repos");
     }
 }
Example #22
0
    /// <summary>
    /// Add a new branch to the path.
    /// New branches are assumed to be brand-new, consisting of nothing more than their default initial node.
    /// </summary>
    /// <param name="branch"></param>
    private void Add(Branch branch)
    {
        if (branch.Count > 1)
        {
            throw new PathException(PATH_EXCEPTION_TYPE.BRANCH_POPULATED);
        }

        Branches.Add(branch.ID, branch);
        OuterBranchIDs.Add(branch.ID);
        SetNodeDirectoryData(branch.InNode);
    }
Example #23
0
        private void AddBranch(object arg)
        {
            var branch = new Branch(BranchName !);

            _mainViewModel.AddBranch(branch);

            Branches.Add(new BranchViewModel(branch));

            BranchName     = string.Empty;
            SelectedBranch = null;
        }
Example #24
0
        public BranchListViewModel(MainViewModel mainViewModel, IEnumerable <Branch> branches)
        {
            _mainViewModel = mainViewModel;

            foreach (var branch in branches)
            {
                Branches.Add(new BranchViewModel(branch));
            }

            AddBranchCommand    = new DelegateCommand(AddBranch, IsBranchNameFilled);
            RemoveBranchCommand = new DelegateCommand(RemoveBranch, IsBranchSelected);
        }
Example #25
0
 private void ChangeGitDirectory()
 {
     using (var repo = new Repository(GitPath))
     {
         foreach (var branch in repo.Branches)
         {
             if (!branch.IsRemote)
             {
                 Branches.Add(branch.FriendlyName);
             }
         }
     }
 }
        private void SetupDataForArithmeticPrecision()
        {
            Lines lines = new Lines();

            lines.Add(1, 1);
            for (int i = 2; i <= 6; i++)
            {
                lines.Add(i, 0);
            }
            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 1, Path = 0, Ordinal = 1
            });
            for (int i = 2; i <= 6; i++)
            {
                branches.Add(new BranchInfo {
                    Line = 1, Hits = 0, Offset = 1, Path = 1, Ordinal = (uint)i
                });
            }

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Tests.CoverageSummaryTests::TestCalculateSummary()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Tests.CoverageSummaryTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            _moduleArithmeticPrecision = new Modules();
            _moduleArithmeticPrecision.Add("module", documents);
        }
        public void initBranches()
        {
            var b1 = new BranchOfficeVM();

            b1.BranchOfficeID = Guid.NewGuid().ToString();
            b1.Name           = "New York";
            Branches.Add(b1);
            var b2 = new BranchOfficeVM();

            b2.BranchOfficeID = Guid.NewGuid().ToString();
            b2.Name           = "London";
            Branches.Add(b2);
        }
        public void TestEnsureParseMethodStringCorrectly(
            string methodString,
            string expectedMethodName,
            string expectedSignature)
        {
            CoverageResult result = new CoverageResult();

            result.Identifier = Guid.NewGuid().ToString();

            Lines lines = new Lines();

            lines.Add(1, 1);

            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });

            Methods methods = new Methods();

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Google.Protobuf.Reflection.MessageDescriptor", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);

            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            CoberturaReporter reporter = new CoberturaReporter();
            string            report   = reporter.Report(result);

            Assert.NotEmpty(report);

            var doc         = XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(report)));
            var methodAttrs = doc.Descendants()
                              .Where(o => o.Name.LocalName == "method")
                              .Attributes()
                              .ToDictionary(o => o.Name.LocalName, o => o.Value);

            Assert.Equal(expectedMethodName, methodAttrs["name"]);
            Assert.Equal(expectedSignature, methodAttrs["signature"]);
        }
Example #29
0
 public static Branches Convert(List <BranchDto> branchsDto)
 {
     if (branchsDto != null)
     {
         Branches branchs = new Branches();
         foreach (BranchDto branchDto in branchsDto)
         {
             Branch item = Convert(branchDto);
             branchs.Add(item);
         }
         return(branchs);
     }
     return(null);
 }
Example #30
0
        void RefreshBranches(IObservableRepository repo)
        {
            Branches.Clear();
            foreach (var branch in repo.Inner.Branches
                     .Select(x => new BranchViewModel {
                Name = x.Name, CanonicalName = x.CanonicalName
            }))
            {
                Branches.Add(branch);
            }

            SelectedBranch = Branches.FirstOrDefault(
                b => b.CanonicalName == repo.Inner.Head.CanonicalName);
        }