Exemplo n.º 1
0
        public void Delayer_DelayAsyncWithNullTestKitBase_ThrowsArgumentNullException()
        {
            //arrange
            Delayer sut = CreateDelayer();

            //act
            Func <Task> act = () => sut.DelayAsync(null, TimeSpan.Zero);

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 2
0
        public async Task Delayer_DelayAsyncWithNegativeDuration_DoesNotDelayAsync()
        {
            //arrange
            TimeSpan duration = TimeSpan.FromSeconds(TestHelper.GenerateNumberBetween(-1000, -1));
            Delayer  sut      = CreateDelayer();

            //act
            Func <Task> act = () => sut.DelayAsync(TestKit, duration);

            //assert
            TimeSpan  expected  = TimeSpan.Zero;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            await act().ConfigureAwait(false);

            stopwatch.Stop();
            stopwatch.Elapsed.Should().BeCloseTo(expected, 250);
        }
Exemplo n.º 3
0
        public async Task Delayer_DelayAsyncWithZeroDuration_DoesNotDelayAsync()
        {
            //arrange
            TimeSpan duration = TimeSpan.Zero;
            Delayer  sut      = CreateDelayer();

            //act
            Func <Task> act = () => sut.DelayAsync(TestKit, duration);

            //assert
            TimeSpan  expected  = TimeSpan.Zero;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            await act().ConfigureAwait(false);

            stopwatch.Stop();
            stopwatch.Elapsed.Should().BeCloseTo(expected, 250);
        }
Exemplo n.º 4
0
        public async Task Delayer_DelayAsyncWithPositiveDuration_DelaysForDilatedDurationAsync()
        {
            //arrange
            TimeSpan duration = TimeSpan.FromSeconds(1);
            Delayer  sut      = CreateDelayer();

            //act
            Func <Task> act = () => sut.DelayAsync(TestKit, duration);

            //assert
            TimeSpan  expected  = TimeSpan.FromSeconds(duration.TotalSeconds * TimeFactor);
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            await act().ConfigureAwait(false);

            stopwatch.Stop();
            stopwatch.Elapsed.Should().BeCloseTo(expected, 250);
        }