public static void Equals_OperatorEqual_OperatorNotEqual(int first, int other, bool expected) { Rune a = new Rune(first); Rune b = new Rune(other); Assert.Equal(expected, Object.Equals(a, b)); Assert.Equal(expected, a.Equals(b)); Assert.Equal(expected, a.Equals((object)b)); Assert.Equal(expected, a == b); Assert.NotEqual(expected, a != b); }
/// <summary> /// Determines whether this <see cref="Rune"/> and a specified <see cref="Rune"/> object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison. /// </summary> /// <remarks> /// Note that because this compares individual characters, a lot of cultural rules do not apply due to multi-char equivalences. This should only be considered to check the cultural casing rules, nothing more. /// </remarks> /// <param name="rune">The <see cref="Rune"/> instance.</param> /// <param name="other">The <see cref="Rune"/> to compare to this instance.</param> /// <param name="comparisonType">One of the enumeration values that specifies how the chars will be compared.</param> /// <returns><see langword="true"/> if the value of the <paramref name="other"/> parameter is the same as this char; otherwise, <see langword="false"/>.</returns> public static Boolean Equals(this Rune rune, Rune other, StringComparison comparisonType) { switch (comparisonType) { case StringComparison.OrdinalIgnoreCase: case StringComparison.InvariantCultureIgnoreCase: return(rune.ToUpperInvariant().Equals(other.ToUpperInvariant())); case StringComparison.CurrentCultureIgnoreCase: return(rune.ToUpper(CultureInfo.CurrentCulture).Equals(other.ToUpper(CultureInfo.CurrentCulture))); default: return(rune.Equals(other)); } }
/// <summary> /// Determines whether this <see cref="Rune"/> and a specified <see cref="Char"/> object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison. /// </summary> /// <remarks> /// Note that because this compares individual characters, a lot of cultural rules do not apply due to multi-char equivalences. This should only be considered to check the cultural casing rules, nothing more. /// </remarks> /// <param name="rune">The <see cref="Rune"/> instance.</param> /// <param name="other">The <see cref="Char"/> to compare to this instance.</param> /// <returns><see langword="true"/> if the value of the <paramref name="other"/> parameter is the same as this char; otherwise, <see langword="false"/>.</returns> public static Boolean Equals(this Rune rune, Char other) => rune.Equals(new Rune(other), StringComparison.CurrentCulture);
/// <summary> /// Determines whether this <see cref="Rune"/> and a specified <see cref="Char"/> object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison. /// </summary> /// <remarks> /// Note that because this compares individual characters, a lot of cultural rules do not apply due to multi-char equivalences. This should only be considered to check the cultural casing rules, nothing more. /// </remarks> /// <param name="rune">The <see cref="Rune"/> instance.</param> /// <param name="other">The <see cref="Char"/> to compare to this instance.</param> /// <param name="comparisonType">One of the enumeration values that specifies how the chars will be compared.</param> /// <returns><see langword="true"/> if the value of the <paramref name="other"/> parameter is the same as this char; otherwise, <see langword="false"/>.</returns> public static Boolean Equals(this Rune rune, Char other, StringComparison comparisonType) => rune.Equals(new Rune(other), comparisonType);