public static void Create()
 {
     DataConfiguration.AddComplexEntity
     (
         new ComplexEntity
         (
             "OrderCustomer",
             false,
             "tblOrder",
             "Ord",
             new List <ComplexEntityLink>()
     {
         new ComplexEntityLink(ComplexEntityLinkType.Inner, "Ord", "Customer", false, "tblCustomer", "Cust", "Id")
     }
         )
     );
     DataConfiguration.AddComplexEntity
     (
         new ComplexEntity
         (
             "OrderDriver",
             true,
             "n2mOrderDriver",
             "OrdDrv",
             new List <ComplexEntityLink>()
     {
         new ComplexEntityLink(ComplexEntityLinkType.Left, "OrdDrv", "Order", false, "tblOrder", "Ord", "Id"),
         new ComplexEntityLink(ComplexEntityLinkType.Left, "OrdDrv", "Driver", false, "tblDriver", "Drv", "Id")
     }
         )
     );
 }
Exemple #2
0
        public void GetDataTableTestWithCondition()
        {
            DataConfiguration dataConfiguration = new DataConfiguration();

            dataConfiguration.ReadConfiguration();

            string query = @"SELECT a.nib FROM so_pos a
                                WHERE a.pos_d > {5/11/14}";

            string query2 = @"SELECT a.nib, a.pac_born, a.pacfam, a.pacname, a.pacsurname, a.pac_sex,
                         a.pos_kno, a.out_kno, a.citycount, a.m_kres,
                         a.pos_t, a.pos_d, a.out_d, a.out_t, a.withmother
                         FROM so_otd b, so_pos a
                            WHERE a.nib = b.nib AND a.pos_d >= {4/1/14} AND a.out_d <= {1/11/15}";

            var queryTable = sqlDataHelper.DoQuery(dataConfiguration.Path, query2);

            Assert.IsTrue(queryTable.Rows.Count > 0);
            Console.WriteLine("Count = {0}", queryTable.Rows.Count);

            /*    foreach (DataRow dataRow in queryTable.Rows)
             *  {
             *      foreach (var item in dataRow.ItemArray)
             *      {
             *          Console.WriteLine(item);
             *      }
             *  } */
        }
        public static BaseDbHelper GetDbHelper()
        {
            try
            {
                DbFactory.dbConfigSection = ConfigurationManager.GetSection("MachineLearning/MachineLearning.Data") as DataConfiguration;
                DbConnection connection = DbFactory.dbConfigSection.DbConnections.Connections[DbFactory.dbConfigSection.DbConnections.DefaultConnection];
                BaseDbHelper baseDbHelper;
                switch (connection.Provider)
                {
                case "MSSQL":
                    baseDbHelper = (BaseDbHelper) new MSSQLHelper();
                    break;

                case "Oracle":
                    baseDbHelper = (BaseDbHelper) new MSSQLHelper();
                    break;

                default:
                    throw new HADataException("", "The data base type " + connection.Provider + " is not recognized.");
                }
                return(baseDbHelper);
            }
            catch (HADataException ex)
            {
                throw ex;
            }
            catch (System.Exception ex)
            {
                throw new HADataException(ex.Message);
            }
        }
Exemple #4
0
 /// <summary>
 /// Configure data access
 /// </summary>
 /// <param name="configuration">Data configuration</param>
 public static void Configure(DataConfiguration configuration)
 {
     if (configuration == null || configuration.Servers == null || configuration.Servers.Count <= 0)
     {
         return;
     }
     foreach (var serverItem in configuration.Servers)
     {
         if (serverItem.Value == null)
         {
             continue;
         }
         //register database provider
         if (!string.IsNullOrWhiteSpace(serverItem.Value.DatabaseProviderFullTypeName))
         {
             IDatabaseProvider provider = (IDatabaseProvider)Activator.CreateInstance(Type.GetType(serverItem.Value.DatabaseProviderFullTypeName));
             ConfigureDatabaseProvider(serverItem.Key, provider);
         }
         //configure entity
         if (!serverItem.Value.EntityConfigurations.IsNullOrEmpty())
         {
             foreach (var entityConfig in serverItem.Value.EntityConfigurations)
             {
                 ConfigureDatabaseServerEntity(serverItem.Key, entityConfig.Key, entityConfig.Value);
             }
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Add the Stage validations
        /// </summary>
        /// <param name="validationType">The type of validation to perform.
        ///     Only the dialog should use the FromDialog type.</param>
        public void addValidations(ValidationType validationType)
        {
            Int32 stageId;

            if (!Int32.TryParse(getId(), out stageId) ||
                stageId < 0 || stageId >= m_maxStages)
            {
                DataConfiguration.addValidation("The stage ID must be within 0 and " + (m_maxStages - 1).ToString());
            }
            else if (stageId != 0 && getDescription().Length == 0)
            {
                DataConfiguration.addValidation("The stage description must be specified (Stage: " + getId() + ")");
            }

            if (validationType.Equals(ValidationType.Complete))
            {
                if (!hasCompletions())
                {
                    DataConfiguration.addValidation("Stage completions are mandatory (Stage: " + getId() + ")");
                }
                else
                {
                    int actionCount;
                    int totalActionCount = 0;
                    foreach (Completion completion in getCompletions())
                    {
                        switch (completion.getCompletionType())
                        {
                        case CompletionType.Fight_Mob:
                        case CompletionType.Use_Skill_On_Mob_Type:
                        case CompletionType.Use_Skill_On_Object:
                            actionCount = completion.getCount();
                            if (actionCount == -1)
                            {
                                // If there is no count then it "counts" as one
                                actionCount = 1;
                            }
                            totalActionCount += actionCount;
                            break;
                        }
                    }
                    if (totalActionCount >= 32)
                    {
                        DataConfiguration.addValidation("There cannot be more than 32 actions in a stage (Stage: " + getId() + ")");
                    }

                    // Verify CompletionType interdependencies

                    /*if (Completion.contains(getCompletions(), CompletionType.Take_Item_To_Location)
                     *  && !Completion.contains(getCompletions(), CompletionType.Nearest_Nav))
                     * {
                     *  DataConfiguration.addValidation("The type '"
                     + CompletionType.Take_Item_To_Location.ToString()
                     + "' requires the '"
                     + CompletionType.Nearest_Nav.ToString()
                     + "' type (Stage: " + getId() + ").");
                     + }*/
                }
            } // ValidationType.Complete
        }
Exemple #6
0
 public static string GetConnectionString()
 {
     return(DataConfiguration.GetConnectionString(
                Environment.GetEnvironmentVariable(ENV_MODE),
                ConnectionStringList
                ));
 }
Exemple #7
0
        private string[] GetDealer_Empl(int DE_UType, int DE_AD_OM_Code)
        {
            DataTable d  = DL_PlacidData.GetDealer_Empl(DE_UType, DE_AD_OM_Code);
            string    _u = DataConfiguration.GetString_Code(d, "DE_AU_Code");

            return(_u.Split(','));
        }
Exemple #8
0
        private string[] GetComm_HisList(long top, int type, int CH_CG_Code, int CH_UType, int CH_AD_OM_Code, DateTime CH_Update_dt)
        {
            DataTable d  = DL_PlacidData.GetComm_HisList(top, type, CH_CG_Code, CH_UType, CH_AD_OM_Code, CH_Update_dt);
            string    _c = DataConfiguration.GetString_Code(d, "CH_Code");

            return(_c.Split(','));
        }
        public ElasticSearchClient(ILogger logger, DataConfiguration settings)
        {
            Check.IsNotNull <ILogger>(logger);
            Check.IsNotNull <List <ConnectionKey> >(settings?.ConfigDictionary, $"Invalid configs for {nameof(ElasticSearchClient<T>)}");

            var keys = settings.ConfigDictionary;

            if (!keys.Any(k => k.Key == Constants.ElasticSearchUrl))
            {
                throw new ArgumentNullException($"Missing config key \"Url\" for {nameof(ElasticSearchClient<T>)}");
            }
            if (!keys.Any(k => k.Key == Constants.ElastiSearchTopic))
            {
                throw new ArgumentNullException($"Missing config key \"Topic\" for {nameof(ElasticSearchClient<T>)}");
            }

            var url   = keys.Single(k => k.Key == Constants.ElasticSearchUrl).Value;
            var index = keys.Single(k => k.Key == Constants.ElastiSearchTopic).Value;

            _publishBatchSize = 10000;

            if (Int32.TryParse(keys.FirstOrDefault(k => k.Key == Constants.ElastiSearchPublishBatchSize).Value, out int batchSize))
            {
                _publishBatchSize = batchSize;
            }

            Check.IsNotNullOrEmpty(url);
            Check.IsNotNullOrEmpty(index);

            logger.LogInformation($"Begin initializing elasticsearch client with url {url} and index {index}");

            var ecSettings = new ConnectionSettings(new Uri(url)).DefaultIndex(index);

            Instance = new ElasticClient(ecSettings);
        }
Exemple #10
0
        /// <summary>
        /// 执行报表的SQL,返回某一列的数组形式 AU_Code
        /// </summary>
        /// <param name="Query"></param>
        /// <returns></returns>
        public string[] GetUserCode(string Query, string Code)
        {
            DataTable U     = QueryExecution(Query);
            string    Codes = DataConfiguration.GetString_Code(U, Code);

            return(Codes.Split(','));
        }
Exemple #11
0
 private void RegisterApis(DataConfiguration config)
 {
     For <IEventsApi>().Use(new EventsApi(config.EventsApi));
     For <IPaymentsEventsApiClient>().Use(new PaymentsEventsApiClient(config.PaymentsEvents));
     For <IAccountApiClient>().Use <AccountApiClient>().Ctor <IAccountApiConfiguration>().Is(config.AccountsApi);
     For <IRoatpClient>().Use(new RoatpApiClient(config.AgreementsApiUrl));
 }
        public DataConfigurationTests()
        {
            var roles = new DataProfile<Role>(() => new Role())
                .ForMember(x => x.Id, (r) => Guid.NewGuid())
                .GenerateForEach(_dataConfiguration, _roleNames, (name, role) => role.Name = name).ToList();

            var products = new DataProfile<Product>(() => new Product())
                .ForMember(x => x.Id, (r) => Guid.NewGuid())
                .ForMember(x=>x.Amount, new DecimalRandomValueCreator(5, 500))
                .GenerateForEach(_dataConfiguration, _productNames, (name, product) => product.Name = name).ToList();

            _dataConfiguration = new DataConfiguration();
            _dataConfiguration.CreateProfileFor(() => new OrderItem())
                .ForMember(x => x.Product, new CollectionItemValueCreator<Product>(products))
                .ForMember(x => x.Quantity, new IntRandomValueCreator(1, 10));

            _dataConfiguration.CreateProfileFor(() => new Order())
                .ForMember(x => x.CreatedOn, (x) => DateTime.UtcNow)
                .FollowPath(x => x.Items, 1, (o) => new OrderItem(o));

            _dataConfiguration.CreateProfileFor(() => new User())
                .FollowPath(x => x.Role)
                .ForMember(x => x.Id, (u) => Guid.NewGuid())
                .ForMember(x => x.FirstName, new RandomStringValueCreator(4, 8))
                .ForMember(x => x.Surname, new CollectionItemValueCreator<string>(_names))
                .ForMember(x => x.Role, new CollectionItemValueCreator<Role>(roles))
                .ForMember(x => x.LogonCount, new IntRandomValueCreator(1, 200))
                .FollowPath(x => x.Orders, 3, 200, (u) => new Order(u));
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddMvc();

            services.AddControllers();
            services.AddAutoMapper(typeof(Startup));

            int chosenDB = Configuration.GetValue("ChosenDB", 1);

            DataConfiguration.configure((DataProviderEnum)chosenDB, Configuration, services);

            ServiceConfiguration.configure(Configuration, services);
            RabbitMqConfiguration.configure(Configuration, services);

            services.AddCors();

            // ********************
            // Setup CORS
            // ********************
            // var corsBuilder = new CorsPolicyBuilder();
            // corsBuilder.AllowAnyHeader();
            // corsBuilder.AllowAnyMethod();
            // corsBuilder.AllowAnyOrigin(); // For anyone access.
            // //corsBuilder.WithOrigins("http://localhost:56573"); // for a specific url. Don't add a forward slash on the end!
            // corsBuilder.AllowCredentials();

            // services.AddCors(options =>
            // {
            //     options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
            // });
        }
Exemple #14
0
        public static void Initialize(TestContext _)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json");

            var configuration = builder.Build();

            configuration.GetSection("DBSettings").Bind(DBSettings);
            DBSettings.SqlProviderFactory = SqlClientFactory.Instance;

            DataConfiguration.Initialize();
            var setup = new DataSetup(DBSettings);

            setup.Initialize();
            setup.LoadUnitTestData();

            WebApiFactory = new WebApplicationFactory <Startup>()
                            .WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    services.Configure <DBSettings>(options =>
                    {
                        options.StorageConnectionString    = DBSettings.StorageConnectionString;
                        options.SqlConnectionString        = DBSettings.SqlConnectionString;
                        options.ReplicaSqlConnectionString = DBSettings.ReplicaSqlConnectionString;
                    });
                });
            });

            StartupWebApiProject();
        }
 public bool Update(DataConfiguration dataConfiguration)
 {
     using (var db = new LiteDatabase(_dbPath))
     {
         var collection = db.GetCollection <DataConfiguration>("DataConfiguration");
         return(collection.Update(dataConfiguration));
     }
 }
 public DocumentRepository(
     CosmosContainerStore containerStore,
     DataConfiguration configuration)
 {
     _configuration     = configuration;
     _containerStore    = containerStore.Guard(nameof(containerStore));
     _partitionKeyValue = configuration.PartitionKey.Guard(nameof(configuration.PartitionKey));
     _partitionKey      = new PartitionKey(_partitionKeyValue);
 }
Exemple #17
0
 public DataConfiguration CreateConfig()
 {
     DataConfiguration config = new DataConfiguration();
     config.DataBaseType = DataBaseType.SqlServer;
     config.IP = getIP();
     config.User = getUser();
     config.Password =  getPwd();
     config.DataBaseName = getDbName();
     return config;
 }
Exemple #18
0
        public void Configure(IUnityContainer container)
        {
            var dataAccessConfiguration = new DataConfiguration();

            dataAccessConfiguration.Configure(container);

            container.RegisterType <IProductService, ProductService>();
            container.RegisterType <IProductCategoryService, ProductCategoryService>();
            container.RegisterType <IProductAttributeLookupService, ProductAttributeLookupService>();
        }
 public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
 {
     InitConfig();
     PresenterConfiguration.Init();
     DataConfiguration.Init();
     DomainConfiguration.Init();
     AppCenter.Start("UUID-for-ios", typeof(Analytics), typeof(Crashes));
     Analytics.SetEnabledAsync(DataConstants.SendAnalytics);
     return(true);
 }
Exemple #20
0
        public static void RegisterDependencies(IServiceCollection services)
        {
            CommonConfiguration.RegisterDependencies(services);
            DataConfiguration.RegisterDependencies(services);

            services.AddTransient <IUserService, UserService>();
            services.AddTransient <IPatientService, PatientService>();
            services.AddTransient <IAppointmentService, AppointmentService>();
            services.AddTransient <ITreatmentService, TreatmentService>();
        }
Exemple #21
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            DataConfiguration.Configure(AOLDataConfig.Configure);

            //var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            //json.SerializerSettings.PreserveReferencesHandling =
            //    Newtonsoft.Json.PreserveReferencesHandling.All;
        }
 public void Arrange()
 {
     _configuration = new DataConfiguration {
         PerformancePlatform = new PerformancePlatformConfiguration {
             Url = "http://localhost/test", Token = "jksnfdg843utnergjg"
         }
     };
     _httpClient = new Mock <IHttpClient>();
     _gateway    = new PerformancePlatformGateway(_configuration, _httpClient.Object);
 }
Exemple #23
0
        protected IDataConfiguration GetConfiguration()
        {
            var dataConfiguration = new DataConfiguration(
                NpgsqlFactory.Instance,
                Fixture.ConnectionString,
                DataCache.Default,
                Output.WriteLine);

            return(dataConfiguration);
        }
Exemple #24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var connectionString   = Configuration.GetConnectionString("ServiceDb");
            var userDbConnString   = Configuration.GetConnectionString("UserDb");
            var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

            services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings"));
            services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings"));
            services.AddOptions();

            services.AddSingleton <IServiceConfigurationAgent, ServiceConfiguration>();
            services.AddTransient <IVerificationProxy, VerificationProxy>();
            services.AddTransient <IWechatProxy, WechatProxy>();
            services.AddTransient <IPaymentServiceProxy, PaymentServiceProxy>();
            services.AddTransient <IUserServiceProxy, UserServiceProxy>();

            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.AddTransient <PartnerAuthCodeValidator>();
            services.AddTransient <VerifyCodeValidator>();
            services.AddTransient <WechatAppletValidator>();

            services.AddScoped <IDbUnitOfWork, DbUnitOfWork>();
            services.AddScoped <IDbContextProvider, DbContextProvider>();

            services.AddDbContext <ConfigurationCustomDbContext>(options => options.UseMySql(connectionString));
            services.AddDbContext <PersistedGrantCustomDbContext>(options => options.UseMySql(connectionString));

            services.AddIdentityServer()
            .AddSigningCredential(new X509Certificate2(@"./certificate/gooios.pfx", "!QAZ2wsx098", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable))
            .AddTestUsers(DataConfiguration.GetUsers().ToList())
            .AddConfigurationStore <ConfigurationCustomDbContext>(options =>
            {
                options.ConfigureDbContext = builder => builder.UseMySql(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
            })
            .AddOperationalStore <PersistedGrantCustomDbContext>(options =>
            {
                options.ConfigureDbContext   = builder => builder.UseMySql(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
                options.EnableTokenCleanup   = true;
                options.TokenCleanupInterval = 7200;
            })
            .AddResourceOwnerValidator <ResourceOwnerPasswordValidator>()
            .AddExtensionGrantValidator <VerifyCodeValidator>()
            .AddExtensionGrantValidator <PartnerAuthCodeValidator>()
            .AddExtensionGrantValidator <WechatAppletValidator>()
            .AddProfileService <ProfileService>();

            services.ConfigureDynamicProxy(config =>
            {
                config.Interceptors.AddTyped <ExceptionInterceptor>(m => m.DeclaringType.Name.EndsWith("AppService"));
                //config.Interceptors.AddTyped<TransactionInterceptor>(m => m.DeclaringType.Name.EndsWith("AppService"));
                config.Interceptors.AddTyped <ProxyInterceptor>(m => m.DeclaringType.Name.EndsWith("Proxy"));
            });
        }
Exemple #25
0
        public DataConfiguration CreateConfig()
        {
            DataConfiguration config = new DataConfiguration();

            config.DataBaseType = DataBaseType.SqlServer;
            config.IP           = getIP();
            config.User         = getUser();
            config.Password     = getPwd();
            config.DataBaseName = getDbName();
            return(config);
        }
Exemple #26
0
        private static void StartSubstituteApis()
        {
            Config = GetAzureStorageConfig();

            EventsApi          = new WebApiSubstitute(Config.EventsApi.BaseUrl, Config.AccountsApi.ApiBaseUrl, Config.PaymentsEvents.ApiBaseUrl, Config.AgreementsApiUrl);
            AccountsApi        = EventsApi;
            ProviderEventsApi  = EventsApi;
            AgreementEventsApi = EventsApi;

            EventsApi.Start();
        }
Exemple #27
0
 public static TransactionScopeFactory NewTransactionScopeFactory()
 {
     if (_TransactionScopeFactory == null)
     {
         DataConfiguration       config  = new DataConfiguration(DataBaseType.SqlServer, ".", "sa", "ynnuyonw", "Elinterface", null);
         TransactionScopeFactory factory = new TransactionScopeFactory();
         factory.DataConfiguration = config;
         factory.Initialize();
         _TransactionScopeFactory = factory;
     }
     return(_TransactionScopeFactory);
 }
Exemple #28
0
 public static TransactionScopeFactory NewTransactionScopeFactory(string key)
 {
     if (_TransactionScopeFactorys[key] == null)
     {
         DataConfiguration       config  = (new DataConfig(@".\" + key + ".xml")).CreateConfig();
         TransactionScopeFactory factory = new TransactionScopeFactory();
         factory.DataConfiguration = config;
         factory.Initialize();
         _TransactionScopeFactorys[key] = factory;
     }
     return((TransactionScopeFactory)_TransactionScopeFactorys[key]);
 }
Exemple #29
0
        public void addValidations()
        {
            if (m_value == null || m_value.Length == 0)
            {
                DataConfiguration.addValidation("The reward value is mandatory");
            }
            else
            {
                Int32 intValue;
                switch (getRewardType())
                {
                case RewardType.Credits:
                case RewardType.Explore_XP:
                case RewardType.Combat_XP:
                case RewardType.Trade_XP:
                    if (!Int32.TryParse(getValue(), out intValue) ||
                        intValue < 0 || intValue > 500000)
                    {
                        DataConfiguration.addValidation("The reward quantity '" + getValue() + "' must be between 1 and 500,000");
                    }
                    break;

                case RewardType.Faction:
                    if (!Int32.TryParse(getValue(), out intValue) ||
                        intValue < 0 || intValue > 500000)
                    {
                        DataConfiguration.addValidation("The reward quantity '" + getValue() + "' must be between 1 and 500,000");
                    }
                    DataConfiguration.addValidation(DataConfiguration.DataType.faction, getFlag());
                    break;

                case RewardType.Item_ID:
                    DataConfiguration.addValidation(DataConfiguration.DataType.item, getValue());
                    break;

                case RewardType.Hull_Upgrade:
                    if (!Int32.TryParse(getValue(), out intValue) ||
                        intValue < 0 || intValue > 6)
                    {
                        DataConfiguration.addValidation("The quantity '" + getValue() + "' must be between 1 and 6");
                    }
                    break;

                case RewardType.Advance_Mission:
                    DataConfiguration.addValidation(DataConfiguration.DataType.mission, getValue());
                    break;

                case RewardType.Run_Script:
                    break;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceConfiguration"/> class.
 /// </summary>
 /// <param name="loggerFactory">The service logging adapter.</param>
 /// <param name="fixConfig">The FIX configuration.</param>
 /// <param name="wireConfig">The wire configuration.</param>
 /// <param name="networkConfig">The network configuration.</param>
 /// <param name="dataConfig">The data configuration.</param>
 public ServiceConfiguration(
     ILoggerFactory loggerFactory,
     FixConfiguration fixConfig,
     WireConfiguration wireConfig,
     NetworkConfiguration networkConfig,
     DataConfiguration dataConfig)
 {
     this.LoggerFactory = loggerFactory;
     this.FixConfig     = fixConfig;
     this.WireConfig    = wireConfig;
     this.NetworkConfig = networkConfig;
     this.DataConfig    = dataConfig;
 }
Exemple #31
0
        public IDataClient <T> GetDataPublisher(DataConfiguration config)
        {
            Logger.LogInformation($"Begin fetching publisher data client");

            if (DataPublisher != null)
            {
                return(DataPublisher);
            }

            Logger.LogInformation($"Initialize new data client for publisher");

            return(DataClientFactory.Create <T>(Logger, config));
        }
Exemple #32
0
        public SqlServerClient(ILogger logger, DataConfiguration settings)
        {
            Check.IsNotNull <ILogger>(logger);
            Check.IsNotNull <List <ConnectionKey> >(settings?.ConfigDictionary, $"Invalid configs for {nameof(SqlServerClient<T>)}");

            var keys = settings.ConfigDictionary;

            if (!keys.Any(k => k.Key == Constants.SqlConnectionKey))
            {
                throw new ArgumentNullException($"Missing config key \"Url\" for {nameof(SqlServerClient<T>)}");
            }

            ConnectionString = keys.Single(k => k.Key == Constants.SqlConnectionKey).Value;
        }
        public void CanCloneAndFiddle()
        {
            var dc = new DataConfiguration();

            IDataProfile<User> userProfile = _dataConfiguration.Get<User>();
            userProfile = userProfile.CloneInto(dc);
            userProfile
                .ForMember(x => x.FirstName, "Jimmy")
                .ForMember(x => x.Role)
                .ForMember(x => x.Orders);

            User user = dc.Get<User>().Generate(dc);
            Assert.NotNull(user);
            Assert.Null(user.Orders);
        }
        public void UsingEmptyCollectionValueCreatorFails()
        {
            var dc = new DataConfiguration();
            IDataProfile<User> userProfile = _dataConfiguration.Get<User>();
            userProfile = userProfile.CloneInto(dc);
            userProfile
                .ForMember(x => x.Surname, new CollectionItemValueCreator<string>(new string[0]))
                .ForMember(x => x.Role);

            Assert.Throws<InvalidOperationException>(() => dc.Get<User>().Generate(dc));
        }
        public void GenerateOneForEach()
        {
            var dc = new DataConfiguration();
            var products = dc.CreateProfileFor(() => new Product())
                .GenerateForEach(dc, _productNames, (name, product) =>
                                                       {
                                                           product.Name = name;
                                                       }).ToList();

            Assert.Equal(3, products.Count);
            foreach(var name in _productNames)
                Assert.Contains(name, products.Select(p=>p.Name));
        }