public MFTestResults AdvancedGetSetTest()
        {
            if (!IsLoopback)
            {
                return(MFTestResults.Skip);
            }

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    // Exercise changing rate while open if port is available
                    serialPort.VerifyWrite();
                    Log.Comment("Change baud and resend");
                    serialPort.BaudRate = (int)BaudRate.Baudrate19200;
                    serialPort.VerifyWrite();
                    Log.Comment("Change Parity and resend");
                    serialPort.Parity = Parity.Even;
                    serialPort.VerifyWrite();
                    Log.Comment("Change StopBit and resend");
                    serialPort.StopBits = StopBits.Two;
                    serialPort.VerifyWrite();
                    Log.Comment("Change DataBits and resend");
                    serialPort.DataBits = 7;
                    serialPort.VerifyWrite();
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return(result);
        }
        public MFTestResults VerifyValidChars()
        {
            if (!IsLoopback)
            {
                return(MFTestResults.Skip);
            }

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Open();
                    for (int i = 1; i < 255; i++)
                    {
                        string data = new string((char)i, 10);
                        Log.FilteredComment("i = " + i + " chars: " + data);
                        serialPort.VerifyWrite(data);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return(result);
        }
        public InitializeResult Initialize()
        {
            Log.Comment("Adding set up for the tests");

            // Add your functionality here.
            portCount = HardwareProvider.HwProvider.GetSerialPortsCount();
            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)  //The Emulator on Windows Host
            {
                IsEmulator = true;
            }
            Debug.Print("IsEmulator: " + IsEmulator);

            // Test for loopback
            sendbuff = Encoding.UTF8.GetBytes(testString);
            Log.Comment("Port count: " + portCount);
            if (portCount > 0)
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.ReadTimeout = 1000;
                    try
                    {
                        serialPort.VerifyWrite(testString);
                        this.IsLoopback = true;
                    }
                    catch
                    {
                        Log.Comment("No loopback detected.  Functional tests will not run");
                    }
                }
            }

            return(InitializeResult.ReadyToGo);
        }
        public InitializeResult Initialize()
        {
            Log.Comment("Adding set up for the tests");

            // Add your functionality here.                
            portCount = HardwareProvider.HwProvider.GetSerialPortsCount();
            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)  //The Emulator on Windows Host
                IsEmulator = true;
            Debug.Print("IsEmulator: " + IsEmulator);

            // Test for loopback
            sendbuff = Encoding.UTF8.GetBytes(testString);
            Log.Comment("Port count: " + portCount);
            if (portCount > 0)
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.ReadTimeout = 1000;
                    try
                    {
                        serialPort.VerifyWrite(testString);
                        this.IsLoopback = true;
                    }
                    catch
                    {
                        Log.Comment("No loopback detected.  Functional tests will not run");
                    }
                }
            }
            
            return InitializeResult.ReadyToGo;            
        }         
        public MFTestResults AdvancedGetSetTest()
        {
            if (!IsLoopback)
                return MFTestResults.Skip;

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    // Exercise changing rate while open if port is available
                    serialPort.VerifyWrite();
                    Log.Comment("Change baud and resend");
                    serialPort.BaudRate = (int)BaudRate.Baudrate19200;
                    serialPort.VerifyWrite();
                    Log.Comment("Change Parity and resend");
                    serialPort.Parity = Parity.Even;
                    serialPort.VerifyWrite();
                    Log.Comment("Change StopBit and resend");
                    serialPort.StopBits = StopBits.Two;
                    serialPort.VerifyWrite();
                    Log.Comment("Change DataBits and resend");
                    serialPort.DataBits = 7;
                    serialPort.VerifyWrite();
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return result;
        }
        public MFTestResults VerifyValidChars()
        {
            if (!IsLoopback)
                return MFTestResults.Skip;

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Open();
                    for (int i = 1; i < 255; i++)
                    {
                        string data = new string((char)i, 10);
                        Log.FilteredComment("i = " + i + " chars: " + data);
                        serialPort.VerifyWrite(data);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return result;
        }