Exemplo n.º 1
0
            public void It_should_Accept_The_Value_Set()
            {
                var target = new InterlockedBoolean(true);

                target.SetValue(true);
                target.GetValue().Should().BeTrue();
                target.SetValue(false);
                target.GetValue().Should().BeFalse();
            }
Exemplo n.º 2
0
 public void ThrowIfReadOnlyInstance()
 {
     if (_isReadOnly.GetValue())
     {
         throw new NotSupportedException(StringResources.TheCurrentInstanceIsReadOnly);
     }
 }
Exemplo n.º 3
0
            public void It_should_Be_Greater_Than_False_When_True()
            {
                var target = new InterlockedBoolean(true);

                target.GetValue().Should().BeTrue();
                target.Should().Be(new InterlockedBoolean(true));
                (target >= false).Should().BeTrue();
                (false <= target).Should().BeTrue();
                (target >= new InterlockedBoolean(false)).Should().BeTrue();
                (new InterlockedBoolean(false) <= target).Should().BeTrue();
                (target > false).Should().BeTrue();
                (false < target).Should().BeTrue();
                (target > new InterlockedBoolean(false)).Should().BeTrue();
                (new InterlockedBoolean(false) < target).Should().BeTrue();
                (target == true).Should().BeTrue();
                (true == target).Should().BeTrue();
                (target == new InterlockedBoolean(true)).Should().BeTrue();
                (new InterlockedBoolean(true) == target).Should().BeTrue();
                (target != false).Should().BeTrue();
                (false != target).Should().BeTrue();
                (target != new InterlockedBoolean(false)).Should().BeTrue();
                (new InterlockedBoolean(false) != target).Should().BeTrue();
                (target <= false).Should().BeFalse();
                (false >= target).Should().BeFalse();
                (target <= new InterlockedBoolean(false)).Should().BeFalse();
                (new InterlockedBoolean(false) >= target).Should().BeFalse();
                (target < false).Should().BeFalse();
                (false > target).Should().BeFalse();
                (target < new InterlockedBoolean(false)).Should().BeFalse();
                (new InterlockedBoolean(false) > target).Should().BeFalse();
                target.As <IComparable <bool> >().Should().BeGreaterThan(false);
                target.As <IComparable <InterlockedBoolean> >().Should().BeGreaterThan(new InterlockedBoolean(false));
                target.CompareTo(false).Should().BeGreaterThan(0);
            }
Exemplo n.º 4
0
            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();
            }
Exemplo n.º 5
0
            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());
            }
Exemplo n.º 6
0
            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());
            }
Exemplo n.º 7
0
            public void It_should_Be_Less_Than_True_When_False()
            {
                var target = new InterlockedBoolean(false);

                target.GetValue().Should().BeFalse();
                target.Should().Be(new InterlockedBoolean(false));
                target.As <IComparable <bool> >().Should().BeLessThan(true);
                target.As <IComparable <InterlockedBoolean> >().Should().BeLessThan(new InterlockedBoolean(true));
                target.As <IComparable>().CompareTo(true).Should().BeLessThan(0);
            }
Exemplo n.º 8
0
 public bool Equals(InterlockedBoolean other)
 {
     return(this.Equals(other.GetValue()));
 }
Exemplo n.º 9
0
 /// <inheritdoc />
 public int CompareTo(InterlockedBoolean other)
 {
     return(this.GetValue().CompareTo(other.GetValue()));
 }