public void Setup()
        {
            ActiveRecordConfiguration.Configure(x => {
                x.ConnectionStringIs("foo");
//				x.MapTypes(typeof(Customer));
            });
        }
Beispiel #2
0
        public void ThrowsWhenNoCurrentScope()
        {
            ActiveRecordConfiguration.Configure(c => {
                c.ConnectionStringIs("foo");
                //c.MapTypes(typeof(Customer));
            });

            typeof(InvalidOperationException).ShouldBeThrownBy(() => { var x = ContextScope.Current; });
        }
Beispiel #3
0
        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;");
        }
Beispiel #4
0
        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;");
        }
Beispiel #5
0
        public void SetsConnectionStringFromConfig()
        {
            ActiveRecordConfiguration.Configure(x => {
                x.ConnectionStringFromConfigFile("foo");
//				x.MapTypes(typeof(Customer));
            });

            ActiveRecordConfiguration.Current.ConnectionString.ShouldEqual("bar");
        }
Beispiel #6
0
        public void SetsMappingSource()
        {
            ActiveRecordConfiguration.Configure(x => {
                x.ConnectionStringIs("foo");
//				x.MapTypes(typeof(Customer));
                x.MappingSource(new AttributeMappingSource());
            });

            ActiveRecordConfiguration.Current.MappingSource.ShouldBe <AttributeMappingSource>();
        }
Beispiel #7
0
        public void SetsCustomScopeStorage()
        {
            ActiveRecordConfiguration.Configure(x => {
                x.ConnectionStringIs("foo");
//				x.MapTypes(typeof(Customer));
                x.ScopeStorage(new TestScopeStorage());
            });

            ActiveRecordConfiguration.Current.ScopeStorage.ShouldBe <TestScopeStorage>();
        }
Beispiel #8
0
        public void CreatesContext()
        {
            ActiveRecordConfiguration.Configure(c => {
                c.ConnectionStringIs("foo");
                //c.MapTypes(typeof(Customer));
            });

            using (new ContextScope()) {
                ContextScope.Current.Context.ShouldNotBeNull();
            }
        }
Beispiel #9
0
        public void SetsCurrentScope()
        {
            ActiveRecordConfiguration.Configure(c => {
                c.ConnectionStringIs("foo");
                //c.MapTypes(typeof(Customer));
            });

            using (var scope = new ContextScope()) {
                ContextScope.Current.ShouldBeTheSameAs(scope);
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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();
        }
Beispiel #14
0
 public void Teardown()
 {
     ActiveRecordConfiguration.Reset();
 }
Beispiel #15
0
 public void Setup()
 {
     ActiveRecordConfiguration.Reset();
 }