示例#1
0
 public void Equals_Invoke_ReturnsExpected(CharacterRange range, object obj, bool expected)
 {
     Assert.Equal(expected, range.Equals(obj));
     if (obj is CharacterRange otherRange)
     {
         Assert.Equal(expected, range.Equals(otherRange));
         Assert.Equal(expected, range == otherRange);
         Assert.Equal(!expected, range != otherRange);
         Assert.Equal(expected, range.GetHashCode().Equals(otherRange.GetHashCode()));
     }
 }
示例#2
0
        public void Equals_WithOtherObject_ReturnsFalse()
        {
            var subjectA = new CharacterRange(char.MinValue, char.MaxValue);
            var subjectB = new object();

            Assert.That(subjectA.Equals(subjectB), Is.False);
        }
示例#3
0
        public void Equals_WithNullReference_ReturnsFalse()
        {
            var subjectA = new CharacterRange(char.MinValue, char.MaxValue);
            var subjectB = (object)null;

            Assert.That(subjectA.Equals(subjectB), Is.False);
        }
示例#4
0
        public void Equals_WhenConstructedWithTheSameCharacters_ReturnsTrue(char min, char max)
        {
            var subjectA = new CharacterRange(min, max);
            var subjectB = new CharacterRange(min, max);

            Assert.That(subjectA.Equals(subjectB), Is.True);
        }
示例#5
0
        public void Equals_WithDifferentMinCharacter_ReturnsFalse(char minA, char minB, char max)
        {
            Assume.That(minA, Is.Not.EqualTo(minB));

            var subjectA = new CharacterRange(minA, max);
            var subjectB = new CharacterRange(minB, max);

            Assert.That(subjectA.Equals(subjectB), Is.False);
        }
示例#6
0
        //</snippet1>

        //<snippet2>
        private void CharacterRangeEquality2()
        {
            // Declare the string to draw.
            string message = "Strings or strings; that is the question.";

            // Compare the ranges for equality. The should not be equal.
            CharacterRange range1 =
                new CharacterRange(message.IndexOf("Strings"), "Strings".Length);
            CharacterRange range2 =
                new CharacterRange(message.IndexOf("strings"), "strings".Length);

            if (range1.Equals(range2))
            {
                MessageBox.Show("The ranges are equal.");
            }
            else
            {
                MessageBox.Show("The ranges are not equal.");
            }
        }
        /// <summary>
        /// Search for the first match in the <see cref="Scintilla"/> text using the properties of this query object.
        /// If it is already selected, replace it with the given string.
        /// </summary>
        /// <param name="editor"><see cref="Scintilla"/> control to search.</param>
        /// <param name="replaceString">String to replace any matches.</param>
        /// <param name="wrap">Set to true to allow the search to wrap back to the beginning of the text.</param>
        /// <returns><see cref="CharacterRange"/> where the result was found.
        /// <see cref="CharacterRange.cpMin"/> will be the same as <see cref="CharacterRange.cpMax"/> if no match was found.</returns>
        public virtual CharacterRange Replace(Scintilla editor, string replaceString, bool wrap)
        {
            CharacterRange searchRange = SearchRange;
            CharacterRange selRange    = new CharacterRange(editor.Selections[0].Start, editor.Selections[0].End);

            SearchRange = selRange;
            if ((selRange.cpMax - selRange.cpMin) > 0)
            {
                if (selRange.Equals(Find(editor)))
                {
                    ReplaceText(editor, replaceString);
                    if (SearchUp)
                    {
                        editor.GotoPosition(selRange.cpMin);
                    }
                }
            }
            SearchRange = searchRange;
            return(FindNext(editor, wrap));
        }
示例#8
0
        public void Equals_NullOther_ThrowsNullReferenceException()
        {
            var range = new CharacterRange();

            Assert.Throws <NullReferenceException>(() => range.Equals(null));
        }