private void SleepWakeAndScan(DateTime endTime, string profileName1)
        {
            testLogger.LogComment("SleepWakeAndScan");

            using (Wlan wlanApi = new Wlan())
            {
                var wlanInterfaceList = wlanApi.EnumWlanInterfaces();
                Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count));
                var wlanInterface = wlanInterfaceList[0];

                if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected)
                {
                    wlanApi.Disconnect(wlanInterface.Id, WlanStress.DisconnectWait);
                }
            }

            Verify.IsTrue(VerifyAPsAreInScanList(profileName1), "Verify APs are in Scan List");

            while (DateTime.Now < endTime)
            {
                WakeHelper.StaticD2Sleep(new TimeSpan(0, 0, 30));

                scanAfterSleepAttempts++;
                if (VerifyAPsAreInScanList(profileName1))
                {
                    scanAfterSleepSuccess++;
                }
            }
        }
        private void SleepWhileConnected(DateTime endTime, string profileName1)
        {
            testLogger.LogComment("SleepWhileConnected");


            using (Wlan wlanApi = new Wlan())
            {
                var wlanInterfaceList = wlanApi.EnumWlanInterfaces();
                Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count));
                var wlanInterface = wlanInterfaceList[0];

                if (wlanInterface.State != WLAN_INTERFACE_STATE.wlan_interface_state_connected)
                {
                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Connecting to {0}", profileName1));
                    wlanApi.ProfileConnect(wlanInterface.Id, profileName1, WlanStress.ConnectWait);
                }

                while (DateTime.Now < endTime)
                {
                    int sleepTime = Random.Next(1, 60);
                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Sleeping for {0} seconds", sleepTime));

                    WakeHelper.StaticD2Sleep(new TimeSpan(0, 0, sleepTime));

                    testLogger.LogComment("Verify we are still connected");
                    connectedAfterSleepAttempts++;
                    if (VerifyWeAreConnected(wlanApi))
                    {
                        testLogger.LogComment("We are still connected");
                        connectedAfterSleepSuccess++;
                    }
                    else
                    {
                        testLogger.LogComment("We are not still connected");
                    }
                    Wlan.Sleep(1000);
                }
            }
        }