コード例 #1
0
        public void IComparableCompareTo_WithParameterEqualToNull_Returns1(int yearNum)
        {
            IComparable calYear = new CalendarYear(yearNum);
            var         comp    = calYear.CompareTo(null);

            Assert.AreEqual(1, comp);
        }
コード例 #2
0
        public void IComparableCompareTo_WithParameterNotOfCalendarYearType_ThrowsArgumentException(int yearNum)
        {
            IComparable calYear = new CalendarYear(yearNum);
            object      obj     = new object();

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            Assert.Throws <ArgumentException>(() => calYear.CompareTo(obj));
        }
コード例 #3
0
        public void IComparableCompareTo_WithParameterIdenticalToInstance_ReturnsZero(int yearNum)
        {
            IComparable calYear1 = new CalendarYear(yearNum);
            object      calYear2 = new CalendarYear(yearNum);
            var         comp     = calYear1.CompareTo(calYear2);

            Assert.AreEqual(0, comp);
        }
コード例 #4
0
        public void IComparableCompareTo_WithParameterLaterThanInstance_ReturnsNegativeNumber(int yearNumInstance, int yearNumParameter)
        {
            IComparable calYear1 = new CalendarYear(yearNumInstance);
            object      calYear2 = new CalendarYear(yearNumParameter);
            var         comp     = calYear1.CompareTo(calYear2);

            Assert.That(comp, Is.LessThan(0));
        }
コード例 #5
0
        public void CompareTo_WithParameterEarlierThanInstance_ReturnsPositiveNumber(int yearNumInstance, int yearNumParameter)
        {
            var calYear1 = new CalendarYear(yearNumInstance);
            var calYear2 = new CalendarYear(yearNumParameter);
            var comp     = calYear1.CompareTo(calYear2);

            Assert.That(comp, Is.GreaterThan(0));
        }