Ejemplo n.º 1
0
        public static void ClassSetup(TestContext context)
        {
            APServer = null;

            if (context.Properties.Contains("DeviceSupports5Ghz"))
            {
                DeviceSupports5Ghz = bool.Parse(context.Properties["DeviceSupports5Ghz"].ToString());
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "DeviceSupports5Ghz = {0}", DeviceSupports5Ghz));
            }

            if (context.Properties.Contains("APServer"))
            {
                APServer = context.Properties["APServer"].ToString();
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "APServer Name = {0}", APServer));
            }
            if (context.Properties.Contains("ServiceAPChannelAddress"))
            {
                ServiceAPChannelAddress = context.Properties["ServiceAPChannelAddress"].ToString();
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "ServiceAPChannelAddress = {0}", ServiceAPChannelAddress));
            }

            if (context.Properties.Contains("Duration"))
            {
                int duration;
                if (Int32.TryParse(context.Properties["Duration"].ToString(), out duration))
                {
                    TestDuration = duration;
                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Duration = {0} minutes", TestDuration));
                }
                else
                {
                    testLogger.LogComment("Could not parse Duration. Using default.");
                }
            }

            if (APServer == null)
            {
                testLogger.LogError("Did not get AP Server name as parameter");
                return;
            }


            testLogger.LogComment("Connecting to AP Config Server - " + APServer);
            using (ApConfigClient apConfigClient = new ApConfigClient(APServer))
            {
                bool connect = apConfigClient.Connect();
                if (connect)
                {
                    testLogger.LogComment("Connection Succeeded");
                }
                else
                {
                    testLogger.LogError("Connection failed");
                    return;
                }

                testLogger.LogComment("Enum Routers");
                routers = apConfigClient.EnumerateAccessPoints();
                if (routers == null)
                {
                    testLogger.LogError("Unable to enum routers, EnumerateAccessPoints returned null");
                    return;
                }
                if (routers.Count >= 2)
                {
                    testLogger.LogComment("Found 2 routers as expected");
                }
                else
                {
                    testLogger.LogError("Did not find both APs");
                    return;
                }
            }
        }