public void Setup() { ActiveRecordConfiguration.Configure(x => { x.ConnectionStringIs("foo"); // x.MapTypes(typeof(Customer)); }); }
public void ThrowsWhenNoCurrentScope() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); }); typeof(InvalidOperationException).ShouldBeThrownBy(() => { var x = ContextScope.Current; }); }
public void BuildsConnectionStringUsingServerNameUserAndPassword() { ActiveRecordConfiguration.Configure(x => { x.ConnectToSqlServer("server", "database", "user", "password"); // x.MapTypes(typeof(Customer)); }); ActiveRecordConfiguration.Current.ConnectionString.ShouldEqual("Data Source=server;Initial Catalog=database;User ID=user;Password=password;"); }
public void BuildsConnectionStringUsingServerName() { ActiveRecordConfiguration.Configure(x => { x.ConnectToSqlServer("server", "database"); // x.MapTypes(typeof(Customer)); }); ActiveRecordConfiguration.Current.ConnectionString.ShouldEqual("Data Source=server;Initial Catalog=database;Integrated Security=SSPI;"); }
public void SetsConnectionStringFromConfig() { ActiveRecordConfiguration.Configure(x => { x.ConnectionStringFromConfigFile("foo"); // x.MapTypes(typeof(Customer)); }); ActiveRecordConfiguration.Current.ConnectionString.ShouldEqual("bar"); }
public void SetsMappingSource() { ActiveRecordConfiguration.Configure(x => { x.ConnectionStringIs("foo"); // x.MapTypes(typeof(Customer)); x.MappingSource(new AttributeMappingSource()); }); ActiveRecordConfiguration.Current.MappingSource.ShouldBe <AttributeMappingSource>(); }
public void SetsCustomScopeStorage() { ActiveRecordConfiguration.Configure(x => { x.ConnectionStringIs("foo"); // x.MapTypes(typeof(Customer)); x.ScopeStorage(new TestScopeStorage()); }); ActiveRecordConfiguration.Current.ScopeStorage.ShouldBe <TestScopeStorage>(); }
public void CreatesContext() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); }); using (new ContextScope()) { ContextScope.Current.Context.ShouldNotBeNull(); } }
public void SetsCurrentScope() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); }); using (var scope = new ContextScope()) { ContextScope.Current.ShouldBeTheSameAs(scope); } }
public void UsesAlternativeScopeStorage() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); c.ScopeStorage(new TestScopeStorage()); }); using (var scope = new ContextScope()) { TestScopeStorage.Scope.ShouldBeTheSameAs(scope); } }
public void SetsContextFactory() { DataContextFactory contextFactory = (connectionString, source) => null; ActiveRecordConfiguration.Configure(x => { x.ConnectionStringIs("foo"); // x.MapTypes(typeof(Customer)); x.DataContextFactory(contextFactory); }); ActiveRecordConfiguration.Current.DataContextFactory.ShouldBeTheSameAs(contextFactory); }
public void BaseTearDown() { ActiveRecordConfiguration.Reset(); var deleteCmd = connection.CreateCommand(); deleteCmd.CommandText = "delete from Customer"; deleteCmd.ExecuteNonQuery(); deleteCmd.CommandText = "delete from Customer2"; deleteCmd.ExecuteNonQuery(); connection.Close(); connection.Dispose(); }
public void BaseSetup() { const string conn = "Data Source=Test.sdf;Persist Security Info=False;"; if (!initialized) { initialized = true; if (File.Exists("Test.sdf")) { File.Delete("Test.sdf"); } using (var engine = new SqlCeEngine(conn)) { engine.CreateDatabase(); } var script = File.ReadAllText("Schema.sql").Split(new[] { "GO" }, StringSplitOptions.RemoveEmptyEntries); using (var c = new SqlCeConnection(conn)) { c.Open(); foreach (var line in script) { var cmd = c.CreateCommand(); cmd.CommandText = line; cmd.ExecuteNonQuery(); } c.Close(); } /* mapping = new FluentMappingSource("Test") * .AddMapping(new CustomerMap());*/ } connection = new SqlCeConnection(conn); connection.Open(); ActiveRecordConfiguration.Configure(cfg => { cfg.ConnectionStringIs(conn); MapTypes(cfg); // cfg.MapTypesFromAssemblyContaining<Customer>(); cfg.DataContextFactory((c, m) => { return(new DataContext(connection, m) { Log = Console.Out }); }); }); // Setup(); }
public void Teardown() { ActiveRecordConfiguration.Reset(); }
public void Setup() { ActiveRecordConfiguration.Reset(); }