public void It_should_Be_False_Upon_Demand() { var target = new InterlockedBoolean(false); target.GetValue().Should().BeFalse(); target.Equals(false).Should().BeTrue(); target.Equals(new InterlockedBoolean(false)).Should().BeTrue(); }
public void It_should_Be_True_Upon_Demand() { var target = new InterlockedBoolean(true); target.GetValue().Should().BeTrue(); target.Equals(true).Should().BeTrue(); target.Equals(new InterlockedBoolean(true)).Should().BeTrue(); target.GetHashCode().Should().Be(true.GetHashCode()); }
public void It_should_Be_False_By_Default() { var target = new InterlockedBoolean(); target.GetValue().Should().BeFalse(); target.Equals(false).Should().BeTrue(); target.Equals(new InterlockedBoolean(false)).Should().BeTrue(); target.GetHashCode().Should().Be(false.GetHashCode()); }
public void It_should_Evaluate_Equality_With_Value_Semantics() { var target = new InterlockedBoolean(true); target.Equals(null).Should().BeFalse(); target.Equals((object)new InterlockedBoolean(true)).Should().BeTrue(); // ReSharper disable once SuspiciousTypeConversion.Global target.Equals((object)true).Should().BeTrue(); target.Equals(new object()).Should().BeFalse(); }
public void TestEquals() { var ibTrue = new InterlockedBoolean(true); var ibAlsoTrue = new InterlockedBoolean(true); var ibFalse = new InterlockedBoolean(false); TestEquality(ibTrue, ibAlsoTrue, true); ibTrue.Equals(true).ShouldBeEquivalentTo(true); ibTrue.Equals(false).ShouldBeEquivalentTo(false); ibFalse.Equals(false).ShouldBeEquivalentTo(true); ibFalse.Equals(true).ShouldBeEquivalentTo(false); }
public void TestEquality(InterlockedBoolean first, InterlockedBoolean second, bool expected) { (first == second).ShouldBeEquivalentTo(expected); first.Equals(second).ShouldBeEquivalentTo(expected); (first.GetHashCode() == second.GetHashCode()).ShouldBeEquivalentTo(expected); (first != second).ShouldBeEquivalentTo(!expected); }