Exemplo n.º 1
0
        public void CannotCallSetPressureOffsetTooHigh()
        {
            AsyncContext.Run(async() =>
            {
                bool offsetCalled;

                var instance = new ServiceSimulation(SynchronizationContext.Current);

                instance.Pressure.Subscribe(_ => offsetCalled = true);

                // reset offsetCalled because it's a behaviorsubject that will always trigger.
                offsetCalled = false;

                Func <Task> act = () => instance.SetPressureOffset(1m, CancellationToken.None);

                await act.Should().ThrowAsync <ArgumentOutOfRangeException>();
                offsetCalled.Should().BeFalse();
            });
        }
Exemplo n.º 2
0
        public void CanCallSetPressureOffset()
        {
            AsyncContext.Run(async() =>
            {
                var instance = new ServiceSimulation(SynchronizationContext.Current);

                decimal actualPressure = 0m;
                decimal actualOffset   = 0m;

                instance.Pressure.Subscribe(p => actualPressure     = p);
                instance.PressureOffset.Subscribe(o => actualOffset = o);

                var targetOffset      = 0.5m;
                var cancellationToken = CancellationToken.None;

                await instance.SetPressureOffset(targetOffset, cancellationToken);

                actualPressure.Should().Be(targetOffset);
                actualOffset.Should().Be(targetOffset);
            });
        }