protected FixtureWithRelationalStore() { var config = new RelationalStoreConfiguration(ConnectionString); config.CommandFactory = new ChaosSqlCommandFactory(new SqlCommandFactory()); config.ApplicationName = "Nevermore-IntegrationTests"; config.DefaultSchema = "TestSchema"; config.DocumentMaps.Register( new CustomerMap(), new BrandMap(), new ProductMap(), new LineItemMap(), new MachineMap(), new OrderMap()); config.TypeHandlers.Register(new ReferenceCollectionTypeHandler()); config.InstanceTypeResolvers.Register(new ProductTypeResolver()); config.InstanceTypeResolvers.Register(new BrandTypeResolver()); config.UseJsonNetSerialization(settings => { settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; }); GenerateSchemaAutomatically( new OrderMap(), new ProductMap(), new CustomerMap(), new LineItemMap(), new BrandMap(), new MachineMap()); Store = new RelationalStore(config); }
private void InitStore() { if (store != null) { return; } if (autoMigrations) { new Migrator(connectionString).Upgrade(); } var jsonSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind, TypeNameHandling = TypeNameHandling.Auto, TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, }; var mappings = new RelationalMappings(); mappings.Install(new[] { new StoredWorkFlowStateMap() }); store = new RelationalStore( connectionString, appName, new SqlCommandFactory(), mappings, jsonSettings, new EmptyRelatedDocumentStore() ); }
public void ShouldSetDefaultConnectionStringOptions() { var store = new RelationalStore("Server=(local);", "Nevermore test", null, null, null, null, 20); var connectionStringBuilder = new SqlConnectionStringBuilder(store.ConnectionString); Assert.Equal(RelationalStore.DefaultConnectTimeoutSeconds, connectionStringBuilder.ConnectTimeout); Assert.Equal(RelationalStore.DefaultConnectRetryCount, connectionStringBuilder.ConnectRetryCount); Assert.Equal(RelationalStore.DefaultConnectRetryInterval, connectionStringBuilder.ConnectRetryInterval); }
public void ShouldNotOverrideExplicitConnectionStringOptions() { var store = new RelationalStore("Server=(local);Connection Timeout=123;ConnectRetryCount=123;ConnectRetryInterval=59;", "Nevermore test", null, null, null, null, 20); var connectionStringBuilder = new SqlConnectionStringBuilder(store.ConnectionString); Assert.Equal(123, connectionStringBuilder.ConnectTimeout); Assert.Equal(123, connectionStringBuilder.ConnectRetryCount); Assert.Equal(59, connectionStringBuilder.ConnectRetryInterval); }
public OrderRepository(string connectionString) { Mappings = new RelationalMappings(); Mappings.Install(new[] { new OrderMap() }); Store = new RelationalStore(connectionString, "OrderService", new SqlCommandFactory(), Mappings, Settings, new EmptyRelatedDocumentStore()); }
public async Task ExecuteTransactionsAreRemovedFromTheRegistryWhenThePoolIsExhausted(Func <RelationalStore, string, Task <IDisposable> > beingTransaction) { var csBuilder = new SqlConnectionStringBuilder(ConnectionString) { ConnectTimeout = 1, MaxPoolSize = 2 }; var store = new RelationalStore(new RelationalStoreConfiguration(csBuilder.ConnectionString)); async Task <IDisposable> TryOpenConnection(int seq) { try { var trn = await beingTransaction(store, "Transaction " + seq); Console.WriteLine($"Transaction {seq}: Opened"); return(trn); } catch (Exception e) { Console.WriteLine($"Transaction {seq}: Failed {e.Message}"); return(null); } } var transactions = await Task.WhenAll( Enumerable.Range(0, 4) .Select(TryOpenConnection) ); foreach (var trn in transactions) { trn?.Dispose(); } var sb = new StringBuilder(); store.WriteCurrentTransactions(sb); sb.ToString().Should().BeEmpty(); }