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 async void ConcurrentBeginConnectTest() { var client = new SignaworksEthernetStackLightManaged(IPForTest, TimeSpan.FromMilliseconds(1000)); //List<Task> tasks = new List<Task>(); for (int i = 0; i < 10; i++) { client.BeginConnect(); } await client.WaitForConnectedAsync(); Assert.True(client.IsConnected); await client.CloseAsync(); Assert.False(client.IsConnected); //await Task.WhenAll(tasks.ToArray()); }