Пример #1
0
        protected static string BuildDefinition(Requirement requirement, NumberFormat numberFormat)
        {
            var builder = new StringBuilder();

            switch (requirement.Type)
            {
            case RequirementType.AddHits:
                builder.Append("AddHits ");
                break;

            case RequirementType.AndNext:
                builder.Append("AndNext ");
                break;
            }

            requirement.AppendString(builder, numberFormat);

            if (requirement.Type == RequirementType.SubSource)
            {
                // change " - " to "-" and add " + " to the end
                builder.Remove(0, 1);
                builder.Remove(1, 1);
                builder.Append(" + ");
            }

            return(builder.ToString());
        }
Пример #2
0
        public void TestAppendStringHex(RequirementType requirementType, TestField left, RequirementOperator requirementOperator, TestField right, int hitCount, string expected)
        {
            var requirement = new Requirement
            {
                Type     = requirementType,
                Left     = GetField(left),
                Operator = requirementOperator,
                Right    = GetField(right),
                HitCount = (uint)hitCount
            };

            var builder = new StringBuilder();

            requirement.AppendString(builder, NumberFormat.Hexadecimal);
            Assert.That(builder.ToString(), Is.EqualTo(expected));
        }
Пример #3
0
        protected string BuildDefinition(Requirement requirement, NumberFormat numberFormat)
        {
            var builder = new StringBuilder();

            switch (requirement.Type)
            {
            case RequirementType.AddHits:
                builder.Append("AddHits ");
                break;

            case RequirementType.SubHits:
                builder.Append("SubHits ");
                break;

            case RequirementType.AndNext:
                builder.Append("AndNext ");
                break;

            case RequirementType.OrNext:
                builder.Append("OrNext ");
                break;
            }

            if (IsValueDependentOnPreviousRequirement)
            {
                var builder2 = new StringBuilder();
                requirement.AppendString(builder2, numberFormat, "~", "~");
                var i = 0;
                while (i < builder2.Length - 1)
                {
                    if (builder2[i + 1] == '~' && builder2[i] == '(')
                    {
                        builder2.Remove(i, 2); // remove "(~"
                        break;
                    }
                    i++;
                }
                while (i < builder2.Length)
                {
                    if (builder2[i] == '~' && builder2[i + 1] == ')')
                    {
                        builder2.Remove(i, 2); // remove "~)"
                        break;
                    }
                    i++;
                }
                builder.Append(builder2);
            }
            else
            {
                requirement.AppendString(builder, numberFormat);
            }

            if (requirement.Type == RequirementType.SubSource)
            {
                // change " - " to "-" and add " + " to the end
                builder.Remove(0, 1);
                builder.Remove(1, 1);
                builder.Append(" + ");
            }

            return(builder.ToString());
        }