示例#1
0
        public void EqualsIsImplemented()
        {
            Torque v = Torque.FromNewtonMeters(1);

            Assert.IsTrue(v.Equals(Torque.FromNewtonMeters(1)));
            Assert.IsFalse(v.Equals(Torque.Zero));
        }
 public void OpEquals()
 {
     var torque1 = new Torque(19.62, TorqueUnit.NewtonMeters);
     var torque2 = new Torque(2, TorqueUnit.KilogramForceMeters);
     var torque3 = new Torque(3, TorqueUnit.KilogramForceMeters);
     (torque1 == torque2).ShouldBeTrue();
     (torque2 == torque1).ShouldBeTrue();
     (torque1 == torque3).ShouldBeFalse();
     (torque3 == torque1).ShouldBeFalse();
     torque1.Equals(torque2)
            .ShouldBeTrue();
     torque1.Equals((object)torque2)
            .ShouldBeTrue();
     torque2.Equals(torque1)
            .ShouldBeTrue();
     torque2.Equals((object)torque1)
            .ShouldBeTrue();
 }
        public void EqualsReturnsFalseOnNull()
        {
            Torque newtonmeter = Torque.FromNewtonMeters(1);

            Assert.False(newtonmeter.Equals(null));
        }
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Torque newtonmeter = Torque.FromNewtonMeters(1);

            Assert.False(newtonmeter.Equals(new object()));
        }