Example #1
0
            public void GivenNullOrNonMatchingTypes_ThenWillThrowException()
            {
                var tt = new MyNumber(TestData.WellKnownInt);

                Assert.That(() => tt.CompareTo((object?)null), Throws.ArgumentNullException);
                Assert.That(() => tt.CompareTo((MyNumber?)null), Throws.ArgumentNullException);
                Assert.That(() => tt.CompareTo(TestData.WellKnownInt), Throws.ArgumentException);
                Assert.That(() => tt.CompareTo(TestData.WellKnownString), Throws.ArgumentException);
            }
Example #2
0
            public void GivenMatchingTypes_ThenWillCompareByUnderlying()
            {
                var tt    = new MyNumber(TestData.WellKnownInt);
                var value = TestData.NextInt();

                Assert.That(tt.CompareTo(new MyNumber(value)), Is.EqualTo(TestData.WellKnownInt.CompareTo(value)));
                Assert.That(tt.CompareTo(new MyNumber(TestData.WellKnownInt)), Is.Zero);
                Assert.That(tt.CompareTo((object)tt), Is.Zero);
                Assert.That(tt.CompareTo(tt), Is.Zero);
            }