Ejemplo n.º 1
0
        private async Task AssertLightSignal(LightSignal lightSignal, int time, Signals expected)
        {
            for (int i = 0; i < time; i++)
            {
                await lightSignal.TickAsync();

                Assert.Equal(expected, lightSignal.State);
            }
        }
Ejemplo n.º 2
0
        public async Task LightSignalTest()
        {
            LightSignal lightSignal = new LightSignal();

            for (int i = 0; i < 5; i++)
            {
                await AssertLightSignal(lightSignal, 30, Signals.Red).ConfigureAwait(false);
                await AssertLightSignal(lightSignal, 5, Signals.Yellow).ConfigureAwait(false);
                await AssertLightSignal(lightSignal, 30, Signals.Green).ConfigureAwait(false);
                await AssertLightSignal(lightSignal, 5, Signals.Yellow).ConfigureAwait(false);
            }
        }