Пример #1
0
        public void EqualsIsImplemented()
        {
            Force v = Force.FromNewtons(1);

            Assert.True(v.Equals(Force.FromNewtons(1)));
            Assert.False(v.Equals(Force.Zero));
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            var other = obj as FormatGeneratorOptions;

            if (other == null)
            {
                throw new PSInvalidOperationException("Object to be compared is of different type "
                                                      + obj.GetType().Name);
            }
            if (((Properties == null) != (other.Properties == null)) ||
                ((GroupBy == null) != (other.GroupBy == null))
                )
            {
                return(false);
            }
            return(
                Expand.Equals(other.Expand) &&
                Force.Equals(other.Force) &&
                ((GroupBy == null && other.GroupBy == null) || GroupBy.Equals(other.GroupBy)) &&
                DisplayError.Equals(other.DisplayError) &&
                ShowError.Equals(other.ShowError) &&
                String.Equals(View, other.View) &&
                ((Properties == null && other.Properties == null) || Properties.Equals(other.Properties))
                );
        }
 public void OpEquals()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var force3 = new Force(2, ForceUnit.KilogramForce);
     (force1 == force2).ShouldBeTrue();
     (force2 == force1).ShouldBeTrue();
     (force1 == force3).ShouldBeFalse();
     (force3 == force1).ShouldBeFalse();
     force1.Equals(force2)
           .ShouldBeTrue();
     force1.Equals((object)force2)
           .ShouldBeTrue();
     force2.Equals(force1)
           .ShouldBeTrue();
     force2.Equals((object)force1)
           .ShouldBeTrue();
 }
Пример #4
0
        public void EqualsReturnsFalseOnNull()
        {
            Force newton = Force.FromNewtons(1);

            Assert.False(newton.Equals(null));
        }
Пример #5
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Force newton = Force.FromNewtons(1);

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