Exemplo n.º 1
0
        internal void Initialize(ref string scenario, ref DataSource source)
        {
            // Ignore all asserts from known issues
            var defaultTraceListener = Trace.Listeners["Default"] as DefaultTraceListener;

            if (defaultTraceListener != null)
            {
                var newTraceListener = new FilteredDefaultTraceListener(defaultTraceListener);
                Trace.Listeners.Remove(defaultTraceListener);
                Trace.Listeners.Add(newTraceListener);
            }

            // scenario <=> SqlClientScenario
            if (string.IsNullOrEmpty(scenario))
            {
                _scenario = SqlClientScenario.Sql;
            }
            else
            {
                _scenario = (SqlClientScenario)Enum.Parse(typeof(SqlClientScenario), scenario, true);
            }
            scenario = _scenario.ToString();

            // initialize the source information
            // SNAC/WDAC is using SqlServer sources; JET is using Access
            switch (_scenario)
            {
            case SqlClientScenario.Sql:
                if (source == null)
                {
                    source = DataStressSettings.Instance.GetDefaultSourceByType(DataSourceType.SqlServer);
                }
                else if (source.Type != DataSourceType.SqlServer)
                {
                    throw new ArgumentException(string.Format("Given source type is wrong: required {0}, received {1}", DataSourceType.SqlServer, source.Type));
                }
                break;

            default:
                throw new ArgumentException("Wrong scenario \"" + scenario + "\"");
            }

            _source = (SqlServerDataSource)source;

            // Only try to add Multisubnet Failover host entries when the settings allow it in the source.
            if (!_source.DisableMultiSubnetFailoverSetup)
            {
                _multiSubnetSetupHelper = new MultiSubnetFailoverSetup(_source);
                _multiSubnetSetupHelper.InitializeFakeHostsForMultiSubnetFailover();
            }
        }
Exemplo n.º 2
0
        internal void Initialize(ref string scenario, ref DataSource source)
        {
            // Ignore all asserts from known issues
            var defaultTraceListener = Trace.Listeners["Default"] as DefaultTraceListener;
            if (defaultTraceListener != null)
            {
                var newTraceListener = new FilteredDefaultTraceListener(defaultTraceListener);
                Trace.Listeners.Remove(defaultTraceListener);
                Trace.Listeners.Add(newTraceListener);
            }

            // scenario <=> SqlClientScenario
            if (string.IsNullOrEmpty(scenario))
            {
                _scenario = SqlClientScenario.Sql;
            }
            else
            {
                _scenario = (SqlClientScenario)Enum.Parse(typeof(SqlClientScenario), scenario, true);
            }
            scenario = _scenario.ToString();

            // initialize the source information
            // SNAC/WDAC is using SqlServer sources; JET is using Access
            switch (_scenario)
            {
                case SqlClientScenario.Sql:
                    if (source == null)
                        source = DataStressSettings.Instance.GetDefaultSourceByType(DataSourceType.SqlServer);
                    else if (source.Type != DataSourceType.SqlServer)
                        throw new ArgumentException(string.Format("Given source type is wrong: required {0}, received {1}", DataSourceType.SqlServer, source.Type));
                    break;

                default:
                    throw new ArgumentException("Wrong scenario \"" + scenario + "\"");
            }

            _source = (SqlServerDataSource)source;

            // Only try to add Multisubnet Failover host entries when the settings allow it in the source.
            if (!_source.DisableMultiSubnetFailoverSetup)
            {
                _multiSubnetSetupHelper = new MultiSubnetFailoverSetup(_source);
                _multiSubnetSetupHelper.InitializeFakeHostsForMultiSubnetFailover();
            }
        }