Example #1
0
 public void CompareToIsImplemented()
 {
     Energy joule = Energy.FromJoules(1);
     Assert.Equal(0, joule.CompareTo(joule));
     Assert.True(joule.CompareTo(Energy.Zero) > 0);
     Assert.True(Energy.Zero.CompareTo(joule) < 0);
 }
Example #2
0
        public void CompareToIsImplemented()
        {
            Energy joule = Energy.FromJoules(1);

            Assert.AreEqual(0, joule.CompareTo(joule));
            Assert.Greater(joule.CompareTo(Energy.Zero), 0);
            Assert.Less(Energy.Zero.CompareTo(joule), 0);
        }
Example #3
0
        public void CompareToThrowsOnNull()
        {
            Energy joule = Energy.FromJoules(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            joule.CompareTo(null);
        }
Example #4
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Energy joule = Energy.FromJoules(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            joule.CompareTo(new object());
        }
Example #5
0
        public void CompareToDoubleTest()
        {
            Energy target   = new Energy(10F);
            double value    = 10F;
            int    expected = 0;
            int    actual;

            actual = target.CompareTo(value);
            Assert.AreEqual(expected, actual);
        }
Example #6
0
        public void CompareToObjectTest()
        {
            Energy target   = new Energy(10F);
            object value    = new Energy(10F);
            int    expected = 10;
            int    actual;

            actual = target.CompareTo(value);
            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public int CompareTo(AllocationNode other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (other is null)
            {
                return(1);
            }
            // compares nodes first by time and then by energy
            var timeComparison = Time.CompareTo(other.Time);

            if (timeComparison != 0)
            {
                return(timeComparison);
            }
            return(Energy.CompareTo(other.Energy));
        }
Example #8
0
        public void CompareToThrowsOnNull()
        {
            Energy joule = Energy.FromJoules(1);

            Assert.Throws <ArgumentNullException>(() => joule.CompareTo(null));
        }
Example #9
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Energy joule = Energy.FromJoules(1);

            Assert.Throws <ArgumentException>(() => joule.CompareTo(new object()));
        }
Example #10
0
 public void CompareToDoubleTest()
 {
     Energy target = new Energy(10F);
     double value = 10F;
     int expected = 0;
     int actual;
     actual = target.CompareTo(value);
     Assert.AreEqual(expected, actual);
 }
Example #11
0
        public void CompareToObjectTest()
        {

            Energy target = new Energy(10F);
            object value = new Energy(10F);
            int expected = 10;
            int actual;
            actual = target.CompareTo(value);
            Assert.AreEqual(expected, actual);

        }