public async void TurnAllLightsOnAndOff() { var client = new SignaworksEthernetStackLightManaged(IPForTest, TimeSpan.FromMilliseconds(1000)); await client.ConnectAsync(); Assert.True(client.IsConnected); foreach (var color in EnumIterator.GetValues <LightColor>()) { await client.TurnLightOnWithConfirmAsync(color); } foreach (var color in EnumIterator.GetValues <LightColor>()) { Assert.True(await client.GetLightStateCurrentAsync(color) == LightState.On); } await Task.Delay(1000); foreach (var color in EnumIterator.GetValues <LightColor>()) { await client.TurnLightOffWithConfirmAsync(color); } foreach (var color in EnumIterator.GetValues <LightColor>()) { Assert.True(await client.GetLightStateCurrentAsync(color) == LightState.Off); } await client.CloseAsync(); Assert.False(client.IsConnected); }
public void Basic_linq_functions_work_on_the_iterator() { EnumIterator.For <DayOfWeek>().First().ShouldBe(DayOfWeek.Sunday); EnumIterator.For <DayOfWeek>().Last().ShouldBe(DayOfWeek.Saturday); EnumIterator.For <DayOfWeek>().Skip(3).Take(1).Single().ShouldBe(DayOfWeek.Wednesday); EnumIterator.For <DayOfWeek>().Any().ShouldBeTrue(); EnumIterator.For <DayOfWeek>().Count().ShouldBe(7); }
public void Ctor_should_succeed_if_enum_type_is_specified() { EnumIterator.For <DayOfWeek>().ShouldNotBeNull(); EnumIterator.For <BindingFlags>().ShouldNotBeNull(); EnumIterator.For(typeof(DayOfWeek)).ShouldNotBeNull(); EnumIterator.For(typeof(BindingFlags)).ShouldNotBeNull(); }
public void Non_generic_enumerator_should_return_all_enum_values_in_correct_order() { List <DayOfWeek> daysOfWeek = EnumIterator.For(typeof(DayOfWeek)).OfType <DayOfWeek>().ToList(); daysOfWeek.Count.ShouldBe(7); daysOfWeek[0].ShouldBe(DayOfWeek.Sunday); daysOfWeek[1].ShouldBe(DayOfWeek.Monday); daysOfWeek[2].ShouldBe(DayOfWeek.Tuesday); daysOfWeek[3].ShouldBe(DayOfWeek.Wednesday); daysOfWeek[4].ShouldBe(DayOfWeek.Thursday); daysOfWeek[5].ShouldBe(DayOfWeek.Friday); daysOfWeek[6].ShouldBe(DayOfWeek.Saturday); }
public void Enumerator_should_return_all_enum_values_in_correct_order() { var daysOfWeek = EnumIterator.For <DayOfWeek>().ToList(); daysOfWeek.Count.ShouldBe(7); daysOfWeek[0].ShouldBe(DayOfWeek.Sunday); daysOfWeek[1].ShouldBe(DayOfWeek.Monday); daysOfWeek[2].ShouldBe(DayOfWeek.Tuesday); daysOfWeek[3].ShouldBe(DayOfWeek.Wednesday); daysOfWeek[4].ShouldBe(DayOfWeek.Thursday); daysOfWeek[5].ShouldBe(DayOfWeek.Friday); daysOfWeek[6].ShouldBe(DayOfWeek.Saturday); }
public void Ctor_should_throw_if_non_enum_type_is_specified() { Should.Throw <ArgumentException>(() => EnumIterator.For <int>()); Should.Throw <ArgumentException>(() => EnumIterator.For <long>()); Should.Throw <ArgumentException>(() => EnumIterator.For <double>()); Should.Throw <ArgumentException>(() => EnumIterator.For <float>()); Should.Throw <ArgumentException>(() => EnumIterator.For <DateTime>()); Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(int))); Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(long))); Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(double))); Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(float))); Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(DateTime))); }
public void Returns_collection_of_enum_values_based_on_type() { var values = EnumIterator.For(typeof(DayOfWeek)).Cast <DayOfWeek>().ToList(); values.Count.ShouldBe(7); values.ShouldBe(new[] { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, }); }
public async void TurnAllColorsOnOff1SecondWithConfirm() { SignaworksEthernetStackLightUnmanaged light = new SignaworksEthernetStackLightUnmanaged(StackLightIPForTest, port: 20000); light.Connect(); Assert.True(light.Connected); foreach (var color in EnumIterator.GetValues <LightColor>()) { await light.TurnLightOnWithConfirmAsync(color); } await Task.Delay(1000); foreach (var color in EnumIterator.GetValues <LightColor>()) { await light.TurnLightOffWithConfirmAsync(color); } light.Close(); Assert.False(light.Connected); }
public void Ctor_should_throw_if_null_is_specified() { Should.Throw <ArgumentNullException>(() => EnumIterator.For(null)); }
public void Throws_if_specified_type_is_not_enum() { Should.Throw <ArgumentException>(() => EnumIterator.For(typeof(EnumIterator_Tests))); }
public void Throws_if_enum_type_is_null() { Should.Throw <ArgumentNullException>(() => EnumIterator.For(null)); }