public async void FlowExtensionsTest() { var v = new WaitValue <DayOfWeek>(DayOfWeek.Monday); _ = Task.Run(async() => { await Task.Delay(TimeSpan.FromMilliseconds(100)); v.Value = DayOfWeek.Friday; }); await v.WaitValuesAsync(fluent.@params(DayOfWeek.Monday, DayOfWeek.Friday)); v.Value = DayOfWeek.Sunday; _ = Task.Run(async() => { await Task.Delay(TimeSpan.FromMilliseconds(100)); v.Value = DayOfWeek.Friday; }); await v.WaitValueAsync(fluent.@params(DayOfWeek.Monday, DayOfWeek.Friday)); }
public async void WaitValuesTest() { for (var index = 0; index < 6; index++) { var v = new WaitValue <DayOfWeek>(DayOfWeek.Sunday); _ = Task.Run(async() => { await Task.Delay(TimeSpan.FromMilliseconds(100)); foreach (var dayOfWeek in fluent.Enum.Values <DayOfWeek>()) { v.Value = dayOfWeek; } }); switch (index) { case 0: Assert.True(await v.WaitValuesAsync(DayOfWeek.Monday, TimeSpan.FromSeconds(1))); break; case 1: Assert.True(await v.WaitValuesAsync(DayOfWeek.Monday, DayOfWeek.Tuesday, TimeSpan.FromSeconds(1))); break; case 2: Assert.True(await v.WaitValuesAsync(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, TimeSpan.FromSeconds(1))); break; case 3: Assert.True(await v.WaitValuesAsync(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, TimeSpan.FromSeconds(1))); break; case 4: Assert.True(await v.WaitValuesAsync(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, TimeSpan.FromSeconds(1))); break; case 5: Assert.True(await v.WaitValuesAsync(fluent.Enum.Values <DayOfWeek>().ToArray(), TimeSpan.FromSeconds(1))); break; } } }