コード例 #1
0
        public async Task Timer_does_not_start_on_subsequent_renders()
        {
            var numberOfCallsToTimerElapsed = 0;

            var component = new TestableTimerComponent {
                TimerElapsed = () => numberOfCallsToTimerElapsed++
            };

            component.CallOnInitialized();
            component.CallOnAfterRender(false);

            await Task.Delay(150);

            numberOfCallsToTimerElapsed.Should().Be(0);
        }
コード例 #2
0
        public async Task Timer_calls_Custom_TimerElapsed_from_component()
        {
            var numberOfCallsToTimerElapsed = 0;

            var component = new TestableTimerComponent {
                CustomTimerElapsed = () => numberOfCallsToTimerElapsed++
            };

            component.CallOnInitialized();
            component.CallOnAfterRender(true);

            await Task.Delay(250);

            numberOfCallsToTimerElapsed.Should().Be(2);
        }
コード例 #3
0
        public async Task Timer_stops_when_disposed()
        {
            var numberOfCallsToTimerElapsed = 0;

            var component = new TestableTimerComponent {
                TimerElapsed = () => numberOfCallsToTimerElapsed++
            };

            component.CallOnInitialized();
            component.CallOnAfterRender(true);

            await Task.Delay(150);

            component.Dispose();

            await Task.Delay(200);

            numberOfCallsToTimerElapsed.Should().Be(1);
        }