public WhatConnectionIsPossible()
 {
     Detect detect = new Detect();
     // Add listener for the ProgressChanged event. This is so we can give user feedback on what is being done right now.
     detect.ProgressChanged += new Detect.ProgressChange(detect_ProgressChanged);
     // Tells detection in what mode it should run. If you dont know what this is you should probably use NoThread.
     // NoThread =           Works in current thread.
     // ThreadInBackground = Works in a thread where IsBackground is set to true.
     // ThreadInForeground = Works in a thread where IsBackground is set to false.
     detect.Start(Detect.WorkMethod.ThreadInBackground);
 }
        public void ConnectionDetection_WorksAllWayToTheEnd()
        {
            Detect det = new Detect();
            det.Port = 9000;
            det.Start(Detect.WorkMethod.NoThread);

            if (det.Progress != Detect.Functions.End)
            {
                throw new AssertFailedException("Detect didn't work it's way all the way to the end.");
            }
        }
        public void ConnectionDetection_GetExternalIp()
        {
            Detect det = new Detect();
            det.Port = 9004;
            det.Start(Detect.WorkMethod.NoThread);

            if (det.ExternalIP != null || det.ExternalIPUPnP != null)
            {
                // This is for debuging test case
                //throw new AssertFailedException(string.Format("{0} : {1}", det.ExternalIP, det.ExternalIPUPnP));
            }
            else
            {
                throw new AssertFailedException("Unable to get External IP Adress");
            }
        }
        public void ConnectionDetection_GetInternalIp()
        {
            Detect det = new Detect();
            det.Port = 9005;
            det.Start(Detect.WorkMethod.NoThread);

            if (det.InternalIP != null)
            {
                // This is for debuging test case
                //throw new AssertFailedException(det.InternalIP.ToString());
            }
            else
            {
                throw new AssertFailedException("Unable to get Internal IP Adress");
            }
        }
        public void ConnectionDetection_DoWeFindAConnection()
        {
            Detect det = new Detect();
            det.Port = 9001;
            det.Start(Detect.WorkMethod.NoThread);

            switch (det.ConnectionType)
            {
                case 0:
                    throw new AssertFailedException("Can't find any usable Internet connection.");
                case 1:
                    throw new AssertFailedException("You only seem to be able to be passive.");
                case 2:
                case 4:
                    break;
                default:
                    throw new AssertFailedException("We got a value that shouldn't be possible");
            }
        }