Example #1
0
        public void Default_value_is_zero()
        {
            var atomicDouble = new AtomicDouble();

            var value = atomicDouble.Get();

            value.Should().Be(0);
        }
Example #2
0
        public void Default_value_is_correctly_assigned_when_specified_in_constructor(double expectedValue)
        {
            var atomicDouble = new AtomicDouble(expectedValue);

            var value = atomicDouble.Get();

            value.Should().Be(expectedValue);
        }
Example #3
0
        public void Compare_and_set_does_not_update_the_value_when_original_value_is_incorrect(double newValue)
        {
            var atomicDouble = new AtomicDouble();

            atomicDouble.CompareAndSet(newValue, 100);

            var value = atomicDouble.Get();

            value.Should().Be(0);
        }
Example #4
0
        public void Get_and_set_updates_the_value_as_specified(double newValue)
        {
            var atomicDouble = new AtomicDouble();

            atomicDouble.GetAndSet(newValue);

            var value = atomicDouble.Get();

            value.Should().Be(newValue);
        }
Example #5
0
        public void Incrementing_the_value_by_the_specified_amount_increments_the_value_correctly(double originvalValue, double amount, double expectedValue)
        {
            var atomicDouble = new AtomicDouble(originvalValue);

            atomicDouble.Increment(amount);

            var value = atomicDouble.Get();

            value.Should().BeApproximately(expectedValue, 0.1);
        }
Example #6
0
        public void Incrementing_the_value_increments_the_value(double originvalValue, double expectedValue)
        {
            var atomicDouble = new AtomicDouble(originvalValue);

            atomicDouble.Increment();

            var value = atomicDouble.Get();

            value.Should().Be(expectedValue);
        }
Example #7
0
        public void Setting_the_value_updates_the_value_as_expected(double newValue)
        {
            var atomicDouble = new AtomicDouble();

            atomicDouble.Set(newValue);

            var value = atomicDouble.Get();

            value.Should().Be(newValue);
        }