public void CompareToTest()
        {
            Radian angle1 = new Radian(2.0);
            Radian angle2 = new Radian(2.0);
            Radian angle3 = new Radian(3.0);

            Assert.AreEqual(angle1.CompareTo(angle2), angle1.Value.CompareTo(angle2.Value));
            Assert.AreEqual(angle1.CompareTo(angle3), angle1.Value.CompareTo(angle3.Value));
            Assert.AreEqual(angle3.CompareTo(angle1), angle3.Value.CompareTo(angle1.Value));
        }
Ejemplo n.º 2
0
        public void Should_compare_with_null_instance(double value)
        {
            var instance = new Radian(value);

            Assert.IsFalse(instance.Equals(null), "Equals");
            Assert.AreEqual(1, instance.CompareTo(null), "CompareTo");
        }
Ejemplo n.º 3
0
        public void Should_compare_with_another_type_of_instance(double value)
        {
            var    instance1 = new Radian(value);
            object instance2 = value;

            Assert.IsFalse(instance1.Equals(instance2), "Equals");
            Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo");
        }
Ejemplo n.º 4
0
        public void Should_compare_with_bigger_value(double baseValue, double biggerValue)
        {
            var baseInstance   = new Radian(baseValue);
            var biggerInstance = new Radian(biggerValue);

            Assert.IsFalse(baseInstance.Equals(biggerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)biggerInstance), "Equals object");

            Assert.IsFalse(baseInstance == biggerInstance, "==");
            Assert.IsTrue(baseInstance != biggerInstance, "!=");

            Assert.AreEqual(-1, baseInstance.CompareTo(biggerInstance), "CompareTo");
            Assert.AreEqual(-1, baseInstance.CompareTo((object)biggerInstance), "CompareTo object");

            Assert.IsTrue(baseInstance < biggerInstance, "<");
            Assert.IsFalse(baseInstance > biggerInstance, ">");

            Assert.IsTrue(baseInstance <= biggerInstance, "<=");
            Assert.IsFalse(baseInstance >= biggerInstance, ">=");
        }
Ejemplo n.º 5
0
        public void Should_compare_with_smaller_value(double baseValue, double smallerValue)
        {
            var baseInstance    = new Radian(baseValue);
            var smallerInstance = new Radian(smallerValue);

            Assert.IsFalse(baseInstance.Equals(smallerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)smallerInstance), "Equals object");

            Assert.IsFalse(baseInstance == smallerInstance, "==");
            Assert.IsTrue(baseInstance != smallerInstance, "!=");

            Assert.AreEqual(+1, baseInstance.CompareTo(smallerInstance), "CompareTo");
            Assert.AreEqual(+1, baseInstance.CompareTo((object)smallerInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < smallerInstance, "<");
            Assert.IsTrue(baseInstance > smallerInstance, ">");

            Assert.IsFalse(baseInstance <= smallerInstance, "<=");
            Assert.IsTrue(baseInstance >= smallerInstance, ">=");
        }
Ejemplo n.º 6
0
        public void Should_compare_with_same_value(double value)
        {
            var baseInstance  = new Radian(value);
            var otherInstance = new Radian(value);

            Assert.IsTrue(baseInstance.Equals(otherInstance), "Equals");
            Assert.IsTrue(baseInstance.Equals((object)otherInstance), "Equals object");

            Assert.IsTrue(baseInstance == otherInstance, "==");
            Assert.IsFalse(baseInstance != otherInstance, "!=");

            Assert.AreEqual(0, baseInstance.CompareTo(otherInstance), "CompareTo");
            Assert.AreEqual(0, baseInstance.CompareTo((object)otherInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < otherInstance, "<");
            Assert.IsFalse(baseInstance > otherInstance, ">");

            Assert.IsTrue(baseInstance <= otherInstance, "<=");
            Assert.IsTrue(baseInstance >= otherInstance, ">=");
        }