public void BaseTestInitialize()
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Formatting = Formatting.None,
                Converters = new JsonConverter[] { new JsonKnownTypeConverter() }
            };

            var container = new UnityContainer().LoadConfiguration();
            this.dataAccess = container.Resolve<IDataAccess>();
            var formMetadata = this.dataAccess.GetProduct("1000");
            var subpageMetadata = this.dataAccess.GetProduct("5000");
            this.controlList = formMetadata.FormDefinition.Pages.AllControls;
            this.subpageControlList = subpageMetadata.FormDefinition.Pages.AllControls;
            this.validatorList = new RegexValidatorList
                                 {
                                     new RegexValidator
                                     {
                                         Id = "1",
                                         Regex = "^((\\+\\d{1,3}[\\- ]?)??(\\(?\\d{1,4}\\)?[\\- ])?((?:\\d{0,5})\\d{3,4}[\\- ]?\\d{3,4}))?$",
                                         Name = "Phone"
                                     }
                                 };

            IEnumerable<Control> flatControls = this.controlList.Flatten();
            this.defaultControlsAccess = new List<ControlAccess>(flatControls.Select(e => new ControlAccess(e.Id, AccessLevel.Write)));
        }
        /// <summary>
        /// Imports the validators and returns a map of old ids to new ids.
        /// </summary>
        /// <param name="userId">The user making the request.</param>
        /// <param name="regexValidatorList">The validators to import.</param>
        /// <returns>A map of validator ids, where the old id is the key and the new id is the value.</returns>
        private Dictionary<string, string> ImportValidators(string userId, RegexValidatorList regexValidatorList)
        {
            Dictionary<string, string> map = new Dictionary<string, string>();
            if (regexValidatorList == null)
            {
                return map;
            }

            RegexValidatorList existingValidators = this.manager.GetValidatorList(true);
            foreach (RegexValidator validator in regexValidatorList)
            {
                string currentId = validator.Id;
                RegexValidator match = existingValidators.FirstOrDefault(v => v.Regex == validator.Regex);
                if (match == null)
                {
                    validator.Id = null;
                    match = this.manager.SaveValidator(validator, userId);
                }

                map.Add(currentId, match.Id);
            }

            return map;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationValidatorFactory"/> class.
 /// </summary>
 /// <param name="allControls">The complete control list.</param>
 /// <param name="controlsAccess">The control access list. Validators will not be created for
 /// controls that are not writeable.</param>
 /// <param name="validatorList">The validator list.</param>
 public ApplicationValidatorFactory(ControlList allControls, List<ControlAccess> controlsAccess, RegexValidatorList validatorList)
 {
     this.allControls = allControls;
     this.controlsAccess = controlsAccess;
     this.validatorList = validatorList;
 }