File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
test/Telegram.Bot.Tests.Unit Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,9 @@ public ChatId(string username)
6868 /// <summary>Compares two ChatId objects</summary>
6969 public static bool operator == ( ChatId ? obj1 , ChatId ? obj2 )
7070 {
71+ if ( ReferenceEquals ( obj1 , obj2 ) ) return true ;
7172 if ( obj1 is null || obj2 is null ) return false ;
72- if ( obj1 . Identifier is not null && obj2 . Identifier is not null )
73- return obj1 . Identifier == obj2 . Identifier ;
74- if ( obj1 . Username is not null && obj2 . Username is not null )
75- return string . Equals ( obj1 . Username , obj2 . Username , StringComparison . Ordinal ) ;
76- return false ;
73+ return obj1 . Identifier == obj2 . Identifier && string . Equals ( obj1 . Username , obj2 . Username , StringComparison . OrdinalIgnoreCase ) ;
7774 }
7875
7976 /// <summary>Compares two ChatId objects</summary>
Original file line number Diff line number Diff line change @@ -123,7 +123,13 @@ public IEnumerator<object[]> GetEnumerator()
123123 yield return [ new ChatId ( 50 ) , new ChatId ( 50 ) , true ] ;
124124 yield return [ new ChatId ( 100 ) , new ChatId ( 50 ) , false ] ;
125125 yield return [ new ChatId ( "@user" ) , new ChatId ( "@user" ) , true ] ;
126+ yield return [ new ChatId ( "@user" ) , new ChatId ( "@USER" ) , true ] ;
127+ yield return [ new ChatId ( 50 ) , new ChatId ( "@user" ) , false ] ;
126128 yield return [ new ChatId ( 50 ) , new ChatId ( "@50" ) , false ] ;
129+ yield return [ new ChatId ( 50 ) , new ChatId ( "50" ) , true ] ;
130+ yield return [ new ChatId ( 50 ) , null ! , false ] ;
131+ yield return [ null ! , new ChatId ( 50 ) , false ] ;
132+ yield return [ null ! , null ! , true ] ;
127133 }
128134
129135 IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
You can’t perform that action at this time.
0 commit comments