Exemplo n.º 1
0
        public void ApplicationName_set_when_name_or_connection_string_ctor()
        {
            IObjectContextAdapter objectContextAdapter = new AppNameContext("Foo");
            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
        }
Exemplo n.º 2
0
        public void ApplicationName_set_when_name_or_connection_string_and_compiled_model_ctor()
        {
            var model = new DbModelBuilder().Build(ProviderRegistry.Sql2008_ProviderInfo);
            IObjectContextAdapter objectContextAdapter = new AppNameContext("Foo", new DbCompiledModel(model));
            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
        }
Exemplo n.º 3
0
        public void ApplicationName_set_when_existing_connection_ctor()
        {
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource         = ".\\sqlexpress",
                IntegratedSecurity = true
            };
            IObjectContextAdapter objectContextAdapter = new AppNameContext(new SqlConnection(connectionStringBuilder.ToString()), true);
            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
        }
Exemplo n.º 4
0
        public void ApplicationName_set_when_existing_connection_and_model_ctor()
        {
            var model = new DbModelBuilder().Build(ProviderRegistry.Sql2008_ProviderInfo);
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource         = ".\\sqlexpress",
                IntegratedSecurity = true
            };
            IObjectContextAdapter objectContextAdapter = new AppNameContext(
                new SqlConnection(connectionStringBuilder.ToString()),
                new DbCompiledModel(model), true);
            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
        }
Exemplo n.º 5
0
        public void ApplicationName_set_when_existing_object_context_ctor()
        {
            var model = new DbModelBuilder().Build(ProviderRegistry.Sql2008_ProviderInfo);
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource         = ".\\sqlexpress",
                IntegratedSecurity = true
            };
            var entityConnection = new EntityConnection(
                model.DatabaseMapping.ToMetadataWorkspace(),
                new SqlConnection(connectionStringBuilder.ToString()));
            var objectContext = new ObjectContext(entityConnection);

            IObjectContextAdapter objectContextAdapter = new AppNameContext(objectContext, true);
            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.Same(objectContext, objectContextAdapter.ObjectContext);
            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
        }
Exemplo n.º 6
0
        public void ApplicationName_set_when_existing_secure_connection_string()
        {
            var model = new DbModelBuilder().Build(ProviderRegistry.Sql2008_ProviderInfo);
            var connectionStringBuilder
                = new SqlConnectionStringBuilder
                {
                DataSource          = ".\\sqlexpress",
                UserID              = "EFTestUser",
                Password            = "******",
                PersistSecurityInfo = false
                };

            var connection = new SqlConnection(connectionStringBuilder.ToString());

            IObjectContextAdapter objectContextAdapter = new AppNameContext(connection, new DbCompiledModel(model), true);

            var storeConnection = ((EntityConnection)objectContextAdapter.ObjectContext.Connection).StoreConnection;

            Assert.True(storeConnection.ConnectionString.Contains("Application Name=EntityFrameworkMUE"));
            Assert.True(storeConnection.ConnectionString.Contains("Password=Password1"));
        }