public static void ComparisonsTest() { TimeOnly timeOnly1 = TimeOnly.FromDateTime(DateTime.Now); TimeOnly timeOnly2 = timeOnly1.Add(new TimeSpan(1)); TimeOnly timeOnly3 = new TimeOnly(timeOnly1.Ticks); Assert.Equal(-1, timeOnly1.CompareTo(timeOnly2)); Assert.Equal(1, timeOnly2.CompareTo(timeOnly1)); Assert.Equal(-1, timeOnly1.CompareTo(timeOnly2)); Assert.Equal(0, timeOnly1.CompareTo(timeOnly3)); Assert.Equal(-1, timeOnly1.CompareTo((object)timeOnly2)); Assert.Equal(1, timeOnly2.CompareTo((object)timeOnly1)); Assert.Equal(-1, timeOnly1.CompareTo((object)timeOnly2)); Assert.Equal(0, timeOnly1.CompareTo((object)timeOnly3)); Assert.True(timeOnly1.Equals(timeOnly3)); Assert.True(timeOnly1.Equals((object)timeOnly3)); Assert.False(timeOnly2.Equals(timeOnly3)); Assert.False(timeOnly2.Equals((object)timeOnly3)); Assert.False(timeOnly2.Equals(null)); Assert.False(timeOnly2.Equals(new object())); }