Exemplo n.º 1
0
 public void Reload()
 {
     lock (this)
     {
         _mode = TestEnvironmentOptions.None;
         _features.Clear();
         _initialized = false;
     }
 }
Exemplo n.º 2
0
        public TestEnvironmentFeature(string name, TestEnvironmentOptions options)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (options == TestEnvironmentOptions.None)
            {
                throw new ArgumentException($"'{name}' test environment feature options are not defined.");
            }

            Name    = name;
            Options = options;
        }
Exemplo n.º 3
0
        protected void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            lock (this)
            {
                if (_initialized)
                {
                    return;
                }

                var modeValue = GetTestEnvironmentModeValue();
                if (!string.IsNullOrWhiteSpace(modeValue))
                {
                    var options = modeValue.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries)
                                  .Select(o => o.Trim())
                                  .ToArray();

                    if (options.Any())
                    {
                        var pairedOptionsList = GetDescriptiveOptions().ToList();
                        foreach (var option in options)
                        {
                            var idx = pairedOptionsList.FindIndex(p =>
                                                                  p.Key.Equals(option, TestEnvOptionStringComparison));
                            if (idx != -1)
                            {
                                _mode |= pairedOptionsList[idx].Value;
                            }
                            else
                            {
                                idx = _supportFeatures.FindIndex(f =>
                                                                 f.Name.Equals(option, TestEnvOptionStringComparison));
                                if (idx != -1)
                                {
                                    _mode |= _supportFeatures[idx].Options;
                                    _features.Add(option);
                                }
                            }
                        }
                    }
                }

                _initialized = true;
            }
        }
Exemplo n.º 4
0
 public TestEnvironmentAttribute(TestEnvironmentOptions options, params string[] features)
 {
     _options  = options;
     _features = features ?? Array.Empty <string>();
 }
Exemplo n.º 5
0
 public bool HasOptions(TestEnvironmentOptions options)
 {
     return(Mode.HasFlag(options));
 }