Example #1
0
        public void WriteXml(XmlWriter writer)
        {
            if (!string.IsNullOrEmpty(Key))
            {
                writer.WriteAttributeString("key", Key);
            }
            if (!string.IsNullOrEmpty(BooleanCompareDelegate))
            {
                writer.WriteAttributeString("boolDelegate", BooleanCompareDelegate);
            }

            writer.WriteAttributeString("logic", Logic.ToString());
            writer.WriteAttributeString("mode", ComparisonMode.ToString());

            if (ExpressionLeft != null)
            {
                writer.WriteStartElement("left");
                writer.WriteAttributeString("type", ExpressionLeft.GetType().ToSimpleType());
                ExpressionLeft.ObjectWriteXml(writer);
                writer.WriteEndElement();
            }

            if (ExpressionRight != null)
            {
                writer.WriteStartElement("right");
                writer.WriteAttributeString("type", ExpressionRight.GetType().ToSimpleType());
                ExpressionRight.ObjectWriteXml(writer);
                writer.WriteEndElement();
            }
        }
    void OnGUI()
    {
        if (assetSettings == null)
        {
            GUILayout.Label("AssetSettings window could not be found.");
        }
        else
        {
            GUILayout.BeginHorizontal();
            //Configuration A
            GUILayout.BeginVertical();
            DrawConfiguration(ref configurationAIndex, ref configurationBIndex, ref configurationAScrollPosition);
            GUILayout.EndVertical();

            //Separator
            GUILayout.Box(string.Empty, edgeBoxStyle, GUILayout.Width(1), GUILayout.MaxWidth(1), GUILayout.ExpandHeight(true));

            //Configuration B
            GUILayout.BeginVertical();
            DrawConfiguration(ref configurationBIndex, ref configurationAIndex, ref configurationBScrollPosition);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            //Comparison mode
            comparisonMode = (ComparisonMode)EditorGUILayout.EnumPopup("Mode: ", comparisonMode, GUILayout.MaxWidth(300));
        }
    }
        public ISolutionUnitTestResultsContext MustReturn(ITestResult testResult, ComparisonMode mode)
        {
            Assert.ArgumentNotNull(testResult, nameof(testResult));

            var list   = Results;
            var result = list.FirstOrDefault(x => testResult.State == x.State && (mode == ComparisonMode.Strict ? testResult.Message.ToString() == x.Message.ToString() : x.Message.ToString().StartsWith(testResult.Message.ToString())));

            if (result == null || (mode == ComparisonMode.StartsWith || result.Detailed != testResult.Detailed))
            {
                if (list.Any())
                {
                    throw new InvalidOperationException($"The test didn't return expected test result, another results were returned instead.\r\n\r\nExpected:{new BulletedList(testResult.ToString()).ToString().EmptyToNull() ?? "[EMPTY]"}\r\nActual:{new BulletedList(list).ToString().EmptyToNull() ?? "[EMPTY]"}");
                }
                else
                {
                    throw new InvalidOperationException($"The test didn't return expected test result:{new BulletedList(testResult.ToString()).ToString().EmptyToNull() ?? "[EMPTY]"}");
                }
            }
            else
            {
                list.Remove(result);
            }

            return(this);
        }
            /// <summary>
            /// Loads from json.
            /// </summary>
            /// <param name="jsonProperty">The json property.</param>
            /// <param name="service">The service.</param>
            internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
            {
                base.LoadFromJson(jsonProperty, service);

                this.value           = jsonProperty.ReadAsJsonObject(XmlElementNames.Constant).ReadAsString(XmlElementNames.Value);
                this.containmentMode = jsonProperty.ReadEnumValue <ContainmentMode>(XmlAttributeNames.ContainmentMode);
                this.comparisonMode  = jsonProperty.ReadEnumValue <ComparisonMode>(XmlAttributeNames.ContainmentComparison);
            }
Example #5
0
 /// <inheritdoc />
 public IEnumerable <IDuplicateFile> CollectCandidates(string path, ComparisonMode mode) =>
 fileCrawler
 .CrawlFiles(path)
 .GroupBy(x => x, new SimpleComparer(mode))
 .Where(grouping => grouping.Count() > 1)
 .Select(grouping => new DuplicateFile
 {
     FilePaths = grouping.Select(file => file.Path)
 });
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainsSubstring"/> class.
 /// </summary>
 /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param>
 /// <param name="value">The value to compare with.</param>
 /// <param name="containmentMode">The containment mode.</param>
 /// <param name="comparisonMode">The comparison mode.</param>
 public ContainsSubstring(
     PropertyDefinitionBase propertyDefinition,
     string value,
     ContainmentMode containmentMode,
     ComparisonMode comparisonMode)
     : this(propertyDefinition, value)
 {
     this.containmentMode = containmentMode;
     this.comparisonMode = comparisonMode;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainsSubstring"/> class.
 /// </summary>
 /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param>
 /// <param name="value">The value to compare with.</param>
 /// <param name="containmentMode">The containment mode.</param>
 /// <param name="comparisonMode">The comparison mode.</param>
 public ContainsSubstring(
     PropertyDefinitionBase propertyDefinition,
     string value,
     ContainmentMode containmentMode,
     ComparisonMode comparisonMode)
     : this(propertyDefinition, value)
 {
     this.containmentMode = containmentMode;
     this.comparisonMode  = comparisonMode;
 }
Example #8
0
        public void Check_Comparison(object input, ComparisonMode comparisonMode, bool expected)
        {
            // given
            var sut = new Is(input, comparisonMode);

            // when
            var result = Evaluator.Evaluate(sut);

            // then
            Assert.Equal(expected, result);
        }
Example #9
0
        public void Check_BuiltIn_Evaluation(object left, ComparisonMode comparisonMode, object right, bool expected)
        {
            // given
            var sut = new If(left, comparisonMode, right);

            // when
            var result = Evaluator.Evaluate(sut);

            // then
            Assert.Equal(expected, result);
        }
 private void PerformFirstPass(string path, ComparisonMode mode)
 {
     var duplicateFiles = duplicateDetectionService.CollectCandidates(path, mode).ToList();
     if (duplicateFiles.Any())
     {
         PerformSecondPass(duplicateFiles, path, mode);
     }
     else
     {
         System.Console.WriteLine($"No duplicate files found in {path} for mode ${mode} in first pass.");
     }
 }
 public DataItemDescriptor(string fullNameL10NKey, Func <TankViewModelBase, TDataSource> defaultDataSourceRetriver, Func <TDataSource, object> valueRetriever,
                           string unitL10NKey, string descriptionL10NKey, string format = "{0}", ComparisonMode comparationMode = ComparisonMode.HigherBetter,
                           double benchmarkRatio = 0.25, bool isDecimal = true)
 {
     this.FullNameL10NKey            = fullNameL10NKey;
     this.DefaultDataSourceRetriever = defaultDataSourceRetriver;
     this.ValueRetriever             = valueRetriever;
     _unit                = App.GetLocalizedString(unitL10NKey);
     this.Format          = format;
     this.Description     = App.GetLocalizedString(descriptionL10NKey);
     this.ComparationMode = comparationMode;
     this.BenchmarkRatio  = benchmarkRatio;
     this.IsDecimal       = isDecimal;
 }
Example #12
0
        public bool Equals(IPrimitive component, ComparisonMode mode)
        {
            if (component == null)
            {
                throw new ArgumentException($"Null component", nameof(component));
            }

            if (this.GetType() != component.GetType())
            {
                return(false);
            }

            return(mode == ComparisonMode.Deep ? Attributes.DeepEquals(component.Attributes) : Attributes.ShallowEquals(component.Attributes));
        }
Example #13
0
        protected override void ReadXmlAttributes(XmlReader reader)
        {
            string valueString = reader.GetAttribute("Value");

            if (valueString != null)
            {
                Value = long.Parse(valueString);
            }
            string comparison = reader.GetAttribute("Comparison");

            if (comparison != null)
            {
                Comparison = (ComparisonMode)Enum.Parse(typeof(ComparisonMode), comparison);
            }
        }
            /// <summary>
            /// Reads the attributes from XML.
            /// </summary>
            /// <param name="reader">The reader.</param>
            internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
            {
                base.ReadAttributesFromXml(reader);

                this.containmentMode = reader.ReadAttributeValue <ContainmentMode>(XmlAttributeNames.ContainmentMode);

                try
                {
                    this.comparisonMode = reader.ReadAttributeValue <ComparisonMode>(XmlAttributeNames.ContainmentComparison);
                }
                catch (ArgumentException)
                {
                    // This will happen if we receive a value that is defined in the EWS schema but that is not defined
                    // in the API (see the comments in ComparisonMode.cs). We map that value to IgnoreCaseAndNonSpacingCharacters.
                    this.comparisonMode = ComparisonMode.IgnoreCaseAndNonSpacingCharacters;
                }
            }
Example #15
0
        private int Comparison(ComparisonMode comparisonMode, int[] program, int currentPosition, int opAndModes)
        {
            var mode1 = (opAndModes / 100) % 10 == 0 ? Mode.Position : Mode.Immediate;
            var mode2 = (opAndModes / 1000) % 10 == 0 ? Mode.Position : Mode.Immediate;
            //var mode3 = (opAndModes / 10000) % 10 == 0 ? Mode.Position : Mode.Immediate;

            var p1Value = mode1 == Mode.Immediate ? program[++currentPosition] : program[program[++currentPosition]];
            var p2Value = mode2 == Mode.Immediate ? program[++currentPosition] : program[program[++currentPosition]];
            //var param3 = mode3 == Mode.Immediate ? program[++current] : program[program[++current]];

            var resultPos = program[++currentPosition];

            var result = comparisonMode == ComparisonMode.LessThan ? p1Value < p2Value : p1Value == p2Value;

            program[resultPos] = result ? 1 : 0;

            return(currentPosition);
        }
        /// <summary>
        ///   Asserts that the thrown exception contains an inner exception with the <paramref name = "expectedInnerMessage" />.
        /// </summary>
        /// <param name = "expectedInnerMessage">The expected message of the inner exception.</param>
        /// <param name = "comparisonMode">Determines how the expected message is compared with the actual message.</param>
        /// <param name = "reason">
        ///   The reason why the message of the inner exception should match <paramref name = "expectedInnerMessage" />.
        /// </param>
        /// <param name = "reasonArgs">The parameters used when formatting the <paramref name = "reason" />.</param>
        public virtual ExceptionAssertions <TException> WithInnerMessage(string expectedInnerMessage,
                                                                         ComparisonMode comparisonMode, string reason, params object[] reasonArgs)
        {
            AssertionScope assertion = Execute.Assertion
                                       .BecauseOf(reason, reasonArgs)
                                       .UsingLineBreaks;

            assertion
            .ForCondition(Subject.Any())
            .FailWith("Expected inner exception{reason}, but no exception was thrown.");

            assertion
            .ForCondition(Subject.Any(e => e.InnerException != null))
            .FailWith("Expected inner exception{reason}, but the thrown exception has no inner exception.");

            string[] subjectInnerMessage = Subject.Select(e => e.InnerException.Message).ToArray();

            ExceptionMessageAssertion messageAssertion = innerMessageAssertions[comparisonMode];

            messageAssertion.Execute(subjectInnerMessage, expectedInnerMessage, reason, reasonArgs);

            return(this);
        }
Example #17
0
 /// <inheritdoc/>
 public void ChangeComparisonMode(ComparisonMode newMode)
 {
     m_impl.ChangeComparisonMode((int) newMode);
 }
        /// <summary>
        ///   Asserts that the thrown exception has a message that matches <paramref name = "expectedMessage" />
        ///   depending on the specified matching mode.
        /// </summary>
        /// <param name = "expectedMessage">
        ///   The expected message of the exception.
        /// </param>
        /// <param name = "comparisonMode">
        ///   Determines how the expected message is compared with the actual message.
        /// </param>
        /// <param name = "reason">
        ///   A formatted phrase as is supported by <see cref = "string.Format(string,object[])" /> explaining why the assertion
        ///   is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name = "reasonArgs">
        ///   Zero or more objects to format using the placeholders in <see cref = "reason" />.
        /// </param>
        public virtual ExceptionAssertions <TException> WithMessage(string expectedMessage, ComparisonMode comparisonMode,
                                                                    string reason = "", params object[] reasonArgs)
        {
            AssertionScope assertion = Execute.Assertion.BecauseOf(reason, reasonArgs).UsingLineBreaks;

            assertion
            .ForCondition(Subject.Any())
            .FailWith("Expected exception with message {0}{reason}, but no exception was thrown.", expectedMessage);

            ExceptionMessageAssertion messageAssertion = outerMessageAssertions[comparisonMode];

            messageAssertion.Execute(Subject.Select(exc => exc.Message).ToArray(), expectedMessage, reason, reasonArgs);

            return(this);
        }
Example #19
0
 /// <summary>
 /// Get the hashcode for a specified <see cref="ComparisonMode"/>
 /// </summary>
 /// <param name="mode"></param>
 /// <returns></returns>
 public int GetHashCode(ComparisonMode mode)
 {
     return(mode == ComparisonMode.Deep ? Attributes.GetDeepHashCode() : Attributes.GetShallowHashCode());
 }
 public void Run(string path, ComparisonMode mode)
 {
     PerformFirstPass(path, mode);
 }
    void OnGUI()
    {
        if(assetSettings == null) {
            GUILayout.Label("AssetSettings window could not be found.");
        } else {
            GUILayout.BeginHorizontal();
                //Configuration A
                GUILayout.BeginVertical();
                    DrawConfiguration(ref configurationAIndex, ref configurationBIndex, ref configurationAScrollPosition);
                GUILayout.EndVertical();

                //Separator
                GUILayout.Box(string.Empty, edgeBoxStyle, GUILayout.Width(1), GUILayout.MaxWidth(1), GUILayout.ExpandHeight(true));

                //Configuration B
                GUILayout.BeginVertical();
                    DrawConfiguration(ref configurationBIndex, ref configurationAIndex, ref configurationBScrollPosition);
                GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            //Comparison mode
            comparisonMode = (ComparisonMode) EditorGUILayout.EnumPopup("Mode: ", comparisonMode, GUILayout.MaxWidth(300));
        }
    }
        private void PerformSecondPass(IEnumerable<IDuplicateFile> duplicateFiles, string path, ComparisonMode mode)
        {
            var candidates = duplicateDetectionService.VerifyCandidates(duplicateFiles).ToList();
            if (candidates.Any())
            {
                System.Console.WriteLine($"Found {candidates.Count} duplicate(s):");
                System.Console.WriteLine();

                foreach (var candidate in candidates)
                {
                    foreach (var filePath in candidate.FilePaths)
                    {
                        System.Console.WriteLine($"{filePath}");
                    }

                    System.Console.WriteLine();
                }
            }
            else
            {
                System.Console.WriteLine($"No duplicate files found in {path} for mode ${mode} in second pass.");
            }
        }
Example #23
0
 /// <summary>
 /// Initialisiert eine neue Klasse
 /// </summary>
 /// <param name="fingerCount">Anzahl der Berührungspunkte</param>
 /// <param name="durationinms">Dauer der Berührung</param>
 /// <param name="mode">Gibt an, wie die Berührungsdauer mit der Duration verglichen wird.</param>
 public FingerHold(int fingerCount, int durationinms, ComparisonMode mode) : base(fingerCount)
 {
     Duration = durationinms;
     Mode     = mode;
 }
Example #24
0
 public MelodyScorer(ComparisonMode mode)
 {
     this.comparisonMode = mode;
 }
Example #25
0
 /// <inheritdoc/>
 public IComparison NewEx(string originalDocId, string modifiedDocId, object renderingSet, string originalDescription, string modifiedDescription, ComparisonMode comparisonMode = ComparisonMode.Unspecified,
     bool showSelectorDialog = false)
 {
     return BuildComparison(m_impl.NewEx(originalDocId, modifiedDocId, renderingSet, (int)comparisonMode, showSelectorDialog, originalDescription, modifiedDescription));
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of <see cref="If"/>.
 /// </summary>
 /// <param name="left">Left input value.</param>
 /// <param name="comparisonMode">How the <paramref name="left"/> is compared to <paramref name="right"/>.</param>
 /// <param name="right">Right input value.</param>
 public If(object left, ComparisonMode comparisonMode, object right)
     : base(ModeToComparison(comparisonMode, left, right), true, false)
 {
 }
Example #27
0
 public TrimContext(bool useTrimValue, double trimValue, ComparisonMode trimComparisonMode)
 {
     UseTrimValue       = useTrimValue;
     TrimValue          = trimValue;
     TrimComparisonMode = trimComparisonMode;
 }
Example #28
0
 /// <summary>
 /// Initializes a new instance of <see cref="If"/>.
 /// </summary>
 /// <param name="value">Input value.</param>
 /// <param name="comparisonMode">Against what the <paramref name="value"/> is compared to.</param>
 public Is(object value, ComparisonMode comparisonMode)
     : base(value)
 {
     _comparisonMode = comparisonMode;
 }
Example #29
0
 /// <summary>
 /// Display only if the value is equal to any of the given value
 /// </summary>
 /// <param name="types"></param>
 public DisplayIfAttribute(string field, params object[] values)
 {
     this.field  = field;
     this.values = values;
     compareMode = ComparisonMode.EQUALS;
 }
Example #30
0
 /// <summary>
 /// Display only if the value is in the range given
 /// </summary>
 /// <param name="field"></param>
 /// <param name="value"></param>
 /// <param name="compareMode"></param>
 public DisplayIfAttribute(string field, object value, ComparisonMode compareMode)
 {
     this.field       = field;
     this.value       = value;
     this.compareMode = compareMode;
 }
 /// <summary>
 ///   Asserts that the thrown exception contains an inner exception with the <paramref name = "expectedInnerMessage" />.
 /// </summary>
 /// <param name = "expectedInnerMessage">The expected message of the inner exception.</param>
 /// <param name = "comparisonMode">Determines how the expected message is compared with the actual message.</param>
 public ExceptionAssertions <TException> WithInnerMessage(string expectedInnerMessage,
                                                          ComparisonMode comparisonMode)
 {
     return(WithInnerMessage(expectedInnerMessage, comparisonMode, null, null));
 }
Example #32
0
 /// <summary>
 /// Create an instance with a specified <see cref="ComparisonMode"/>
 /// </summary>
 /// <param name="mode"></param>
 protected PrimitiveEqualityComparer(ComparisonMode mode)
 {
     _mode = mode;
 }
Example #33
0
 public StatAttribute(string nameL10N, ComparisonMode comparisonMode)
     : base(nameL10N)
 {
     this.ComparisonMode = comparisonMode;
 }
            /// <summary>
            /// Reads the attributes from XML.
            /// </summary>
            /// <param name="reader">The reader.</param>
            internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
            {
                base.ReadAttributesFromXml(reader);

                this.containmentMode = reader.ReadAttributeValue<ContainmentMode>(XmlAttributeNames.ContainmentMode);

                try
                {
                    this.comparisonMode = reader.ReadAttributeValue<ComparisonMode>(XmlAttributeNames.ContainmentComparison);
                }
                catch (ArgumentException)
                {
                    // This will happen if we receive a value that is defined in the EWS schema but that is not defined
                    // in the API (see the comments in ComparisonMode.cs). We map that value to IgnoreCaseAndNonSpacingCharacters.
                    this.comparisonMode = ComparisonMode.IgnoreCaseAndNonSpacingCharacters;
                }
            }
Example #35
0
 public MelodyScorer()
 {
     this.comparisonMode = ComparisonMode.Loose;
 }