Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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.");
            }
        }
Ejemplo n.º 3
0
        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");
            }
        }
Ejemplo n.º 4
0
        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");
            }
        }
Ejemplo n.º 5
0
 void detect_ProgressChanged(Detect sender, Detect.Functions prog)
 {
     switch (prog)
     {
         case Detect.Functions.Start:
             Console.WriteLine("Connection detection has started");
             break;
         case Detect.Functions.End:
             Console.WriteLine("Finished");
             Console.Write("Connection Mode:");
             switch (sender.ConnectionType)
             {
                 case 0:     // No Internet Access?
                     Console.WriteLine("It seems like you have no Internet connection.");
                     Console.WriteLine("External IP:" + sender.ExternalIP);
                     break;
                 case 1:     // Passive mode
                     Console.WriteLine("It seems like you can only be passive.");
                     Console.WriteLine("External IP:" + sender.ExternalIP);
                     break;
                 case 2:     // Active mode
                     Console.WriteLine("It seems like you can be active. Congratulations!");
                     Console.WriteLine("External IP:" + sender.ExternalIP);
                     break;
                 case 4:     // Active mode through UPnP
                     Console.WriteLine("It seems like you can be active (Through UPnP). Congratulations!");
                     if (sender.ExternalIP != sender.ExternalIPUPnP)
                     {
                         Console.WriteLine("External IP:" + sender.ExternalIP);
                         Console.WriteLine("External IP (According to your IGD):" + sender.ExternalIPUPnP);
                     }
                     else
                     {
                         Console.WriteLine("External IP:" + sender.ExternalIP);
                     }
                     Console.WriteLine("Internal IP:" + sender.InternalIP);
                     break;
             }
             Console.WriteLine("Port:" + sender.Port);
             break;
         default:
             Console.WriteLine("Working on:" + prog);
             break;
     }
 }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
 protected void OnSuccessChanged(Detect sender, Detect.Functions prog)
 {
 }
Ejemplo n.º 8
0
 protected void OnSuccessChanged(Detect sender, Detect.Functions prog)
 {
 }