コード例 #1
0
        public void EqualsIsImplemented()
        {
            ElectricResistance v = ElectricResistance.FromOhms(1);

            Assert.True(v.Equals(ElectricResistance.FromOhms(1), ElectricResistance.FromOhms(OhmsTolerance)));
            Assert.False(v.Equals(ElectricResistance.Zero, ElectricResistance.FromOhms(OhmsTolerance)));
        }
コード例 #2
0
        public void EqualsIsImplemented()
        {
            ElectricResistance v = ElectricResistance.FromOhms(1);

            Assert.IsTrue(v.Equals(ElectricResistance.FromOhms(1)));
            Assert.IsFalse(v.Equals(ElectricResistance.Zero));
        }
コード例 #3
0
 public void OpEquals()
 {
     var resistance1 = new ElectricResistance(3000, ElectricResistanceUnit.Ohm);
     var resistance2 = new ElectricResistance(3, ElectricResistanceUnit.Kiloohm);
     var resistance3 = new ElectricResistance(4, ElectricResistanceUnit.Kiloohm);
     (resistance1 == resistance2).ShouldBeTrue();
     (resistance2 == resistance1).ShouldBeTrue();
     (resistance1 == resistance3).ShouldBeFalse();
     (resistance3 == resistance1).ShouldBeFalse();
     resistance1.Equals(resistance2)
                .ShouldBeTrue();
     resistance1.Equals((object)resistance2)
                .ShouldBeTrue();
     resistance2.Equals(resistance1)
                .ShouldBeTrue();
     resistance2.Equals((object)resistance1)
                .ShouldBeTrue();
 }
コード例 #4
0
        public void EqualsReturnsFalseOnNull()
        {
            ElectricResistance ohm = ElectricResistance.FromOhms(1);

            Assert.False(ohm.Equals(null));
        }
コード例 #5
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ElectricResistance ohm = ElectricResistance.FromOhms(1);

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