/// <summary>
 /// Checks whether the specified volume is in range.
 /// </summary>
 /// <param name="volume">The volume.</param>
 /// <param name="parameterName">Name of the parameter.</param>
 /// <param name="usage">The usage.</param>
 internal static void VerifyVolumeInRange(Volume volume, string parameterName = null, string usage = null)
 {
     if (volume.CompareTo(Volume.MinValue) < 0 || volume.CompareTo(Volume.MaxValue) > 0)
     {
         throw new ArgumentException($"{usage ?? "Volume"} must be between {Volume.MinValue.Value} and {Volume.MaxValue.Value}.", parameterName ?? nameof(volume));
     }
 }
 public void CompareToIsImplemented()
 {
     Volume cubicmeter = Volume.FromCubicMeters(1);
     Assert.AreEqual(0, cubicmeter.CompareTo(cubicmeter));
     Assert.Greater(cubicmeter.CompareTo(Volume.Zero), 0);
     Assert.Less(Volume.Zero.CompareTo(cubicmeter), 0);
 }
Exemple #3
0
        public void CompareToIsImplemented()
        {
            Volume cubicmeter = Volume.FromCubicMeters(1);

            Assert.Equal(0, cubicmeter.CompareTo(cubicmeter));
            Assert.True(cubicmeter.CompareTo(Volume.Zero) > 0);
            Assert.True(Volume.Zero.CompareTo(cubicmeter) < 0);
        }
Exemple #4
0
        public void CompareToThrowsOnNull()
        {
            Volume cubicmeter = Volume.FromCubicMeters(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            cubicmeter.CompareTo(null);
        }
Exemple #5
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Volume cubicmeter = Volume.FromCubicMeters(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            cubicmeter.CompareTo(new object());
        }
Exemple #6
0
 public int CompareTo(Cilindar other)
 {
     if (ReferenceEquals(this, other))
     {
         return(0);
     }
     return(ReferenceEquals(null, other) ? 1 : Volume.CompareTo(other.Volume));
 }
Exemple #7
0
        /// <summary>
        /// Implementation IComparable.
        /// </summary>
        /// <param name="another"> Other block </param>
        /// <returns> -1, 1, or 0 </returns>
        public int CompareTo(object another)
        {
            if (!(another is Block3D))
            {
                throw new TypeLoadException();
            }

            var anotherBlock = (Block3D)another;

            return(Volume.CompareTo(anotherBlock.Volume));
        }
Exemple #8
0
        public int CompareTo(object iOther)
        {
            if (iOther is RoyalGazette)
            {
                Int32        retval = 0;
                RoyalGazette value2 = (RoyalGazette)iOther;

                retval = Volume.CompareTo(value2.Volume);
                if (retval == 0)
                {
                    retval = Issue.CompareTo(value2.Issue);
                    if (retval == 0)
                    {
                        retval = PageInfo.CompareTo(value2.PageInfo);
                    }
                }
                return(retval);
            }
            throw new InvalidCastException("Not a RoyalGazette");
        }
        public void CompareTo_ShouldProduceDesiredResults()
        {
            // Arrange.
            var targetOne   = new Volume(1.0d);
            var targetTwo   = new Volume(1.0d);
            var targetThree = new Volume(1.0000000000001d);
            var targetFour  = new Volume(1.0000000000002d);

            // Act.
            var resultOne   = targetOne.CompareTo(targetTwo) == 0;
            var resultTwo   = targetTwo.CompareTo(targetThree) == -1;
            var resultThree = targetTwo < targetOne;
            var resultFour  = targetThree > targetOne;
            var resultFive  = targetFour <= targetThree;
            var resultSix   = targetTwo >= targetOne;

            // Assert.
            resultOne.Should().BeTrue();
            resultTwo.Should().BeTrue();
            resultThree.Should().BeFalse();
            resultFour.Should().BeTrue();
            resultFive.Should().BeFalse();
            resultSix.Should().BeTrue();
        }
Exemple #10
0
 public void CompareToObjectTest()
 {
     Volume target = new Volume(10F);
     object value = new Volume(10F);
     int expected = 0;
     int actual;
     actual = target.CompareTo(value);
     Assert.AreEqual(expected, actual);
 }
Exemple #11
0
 public void CompareToDoubleTest()
 {
     Volume target = new Volume(10F);
     double value = 10F;
     int expected = 0;
     int actual;
     actual = target.CompareTo(value);
     Assert.AreEqual(expected, actual);
 }
Exemple #12
0
        public void CompareToThrowsOnNull()
        {
            Volume cubicmeter = Volume.FromCubicMeters(1);

            Assert.Throws <ArgumentNullException>(() => cubicmeter.CompareTo(null));
        }
Exemple #13
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Volume cubicmeter = Volume.FromCubicMeters(1);

            Assert.Throws <ArgumentException>(() => cubicmeter.CompareTo(new object()));
        }