Exemplo n.º 1
0
        /// <summary>
        ///     Creates REST channel and registers loggers.
        /// </summary>
        private void Initialize(Uri cmUrl, NetworkCredential credential, IEnumerable <ILogger> loggers)
        {
            // create REST channel
            var factory = new CmRestChannelFactory <IChassisManager>(cmUrl.ToString());

            factory.Timeout = 1000 * CmConstants.RequestTimeoutSeconds;
            if (credential != null)
            {
                factory.Credential = credential;
            }
            this.channel = factory.CreateChannel();

            // if no loggers specifid, use default
            if (loggers == null)
            {
                loggers = new Collection <ILogger>
                {
                    new TxtFileLogger(TestLogName.Instance),
                    new ConsoleLogger()
                };
            }
            // register loggers
            foreach (ILogger log in loggers)
            {
                Log.Loggers.Add(log);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates REST channel and registers loggers.
        /// </summary>
        private void InitializeRestChannelCollection(Uri cMUri, string userName, string userPassword)
        {
            var testUsersCollection = new Dictionary <int, string>();

            // These users names can be changed in the app.config
            string AutoWcsAdmin    = System.Configuration.ConfigurationManager.AppSettings["AutoAdmin"];
            string AutoWcsOperator = System.Configuration.ConfigurationManager.AppSettings["AutoOperator"];
            string AutoWcsUser     = System.Configuration.ConfigurationManager.AppSettings["AutoUser"];

            // Default Test CM users
            // These users are created for Automation and destroyed as needed
            testUsersCollection.Add((int)WCSSecurityRole.WcsCmAdmin, AutoWcsAdmin);
            testUsersCollection.Add((int)WCSSecurityRole.WcsCmOperator, AutoWcsOperator);
            testUsersCollection.Add((int)WCSSecurityRole.WcsCmUser, AutoWcsUser);
            testUsersCollection.Add(CmConstants.TestConnectionLocalUserId, "LocalTestUser");
            testUsersCollection.Add(CmConstants.TestConnectionDomainUserId, "WcsTestUser");
            // This is already created for WCS Lab domain

            foreach (var testUser in testUsersCollection)
            {
                try
                {
                    var factory = new CmRestChannelFactory <IChassisManager>(cMUri.ToString());
                    factory.Timeout    = 1000 * CmConstants.RequestTimeoutSeconds;
                    factory.Credential = new NetworkCredential(testUser.Value, userPassword);

                    this.restChannelContexts.Add(testUser.Key, factory.CreateChannel());
                }
                catch
                {
                    // To Do Check of Channel collection is creating correctly
                }
            }
        }