using System.Threading;
using Microsoft.SPOT;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CPFUnitTests.UT_MotherBoard
{
    [TestClass]
    public class UnitTest_MotherBoard_GPIO
    {

        public UnitTest_MotherBoard_GPIO()
        {


        }

        [TestMethod]
        public void TestBlinkDebugLED()
        {
            Debug.Print("Unit Test Blink Debug LED.");
            HWModules.MotherBoard mb = HWModules.MotherBoard.Instance;
            int i = 10;
            while (--i > 0)
            {
                mb.ToggleDebugLED();
                Thread.Sleep(1000);
            }
        }

        [TestMethod]
        public void Test12VControl()
        {
            Debug.Print("Unit Test 12V Controller.");
            HWModules.MotherBoard mb = HWModules.MotherBoard.Instance;
            Debug.Print("Enabling 12V...");
            mb.Enable12V();
            Thread.Sleep(10000);
            Debug.Print("Disabling 12V...");
            mb.Disable12V();
        }

        [TestMethod]
        public void Test5VControl()
        {
            Debug.Print("Unit Test 5V Controller.");
            HWModules.MotherBoard mb = HWModules.MotherBoard.Instance;
            Debug.Print("Enabling 5V...");
            mb.Enable5V();
            Thread.Sleep(10000);
            Debug.Print("Disabling 5V...");
            mb.Disable5V();
        }

        [TestMethod]
        public void TestPumpEnable()
        {
            Debug.Print("Unit Test Pump Enable");

            Debug.Print("Enabling Pump");
            var lheBoard = HWModules.LheBoard.Instance;
            lheBoard.EnablePumpPower(true);
            Thread.Sleep(10000);
            Debug.Print("Disabling Pump");
            lheBoard.EnablePumpPower(false);
        }

        [TestMethod]
        public void TestChannelPowerIO()
        {
            Debug.Print("Unit Test Power IO");
            HWModules.MotherBoard mb = HWModules.MotherBoard.Instance;
            int i;
            for (i = 1; i < 16; i++)
            {
                Debug.Print("Enabling Channel: " + i.ToString());
                mb.EnableChannelPower(i);
                Thread.Sleep(5000);
                Debug.Print("Disabling Channel: " + i.ToString());
                mb.DisableChannelPower(i);
                mb.ToggleDebugLED();
                Thread.Sleep(1000);
                mb.ToggleDebugLED();
            }
        }

        [TestMethod]
        public void TestChannelFaultInputs()
        {
            HWModules.MotherBoard mb = HWModules.MotherBoard.Instance; // make sure its initialized. 

            Debug.Print("You have 30 Seconds to pull faults low");
            Thread.Sleep(30000);
            Debug.Print("Test Complete");

        }



    }
}
