Exemplo n.º 1
0
        public void SetUp(DataSet dataSource)
        {
            if (dataSource is NorthwindDataSet)
            {
                Assert.Ignore("Northwind is buggy... because import in VC# is buggy");
            }
            this.Admin.CreateDatabase();

            dataSource.EnforceConstraints = true;
            this.graph = DataGraph.Create(dataSource);

            this.pop = new DatabasePopulator();
            this.pop.Populate(dataSource);

            // add one row data per table
            foreach (DataTable table in this.graph.GetSortedTables())
            {
                ITablePopulator tp = this.pop.Tables[table];
                tp.Generate();
                table.Rows.Add(tp.Row);
                table.AcceptChanges();
            }

            this.gen = new SqlGenerator(
                this.ConnectionString,
                this.DatabaseName,
                dataSource
                );
        }
Exemplo n.º 2
0
        internal void PopulateForeignKeys()
        {
            foreach (Constraint constraint in this.Table.Constraints)
            {
                ForeignKeyConstraint fk = constraint as ForeignKeyConstraint;
                if (fk == null)
                {
                    continue;
                }

                ITablePopulator foreignTable = null;
                if (fk.RelatedTable == this.Table)
                {
                    foreignTable = this;
                }
                else
                {
                    foreignTable = this.database.Tables[fk.RelatedTable];
                }

                // create and add
                IForeignKeyProvider fkp = new ForeignKeyProvider(foreignTable, fk);
                this.foreignKeys.Add(fkp);
            }
        }
Exemplo n.º 3
0
 public ForeignKeyProviderCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulator = new WeakReference(tablePopulator);
 }
Exemplo n.º 4
0
 public SqlCommandUniqueValidator(
     ITablePopulator table,
     UniqueConstraint unique,
     string connectionString
     )
     : base(table, unique, new SqlFactory(), connectionString)
 {
 }
Exemplo n.º 5
0
        public void AddProduct()
        {
            ITablePopulator products = this.pop.Tables[this.db.Products];

            this.db.Products.Rows.Add(products.Generate());
            Console.WriteLine("AddProduct");
            this.Check();
        }
Exemplo n.º 6
0
        public void AddOrder()
        {
            ITablePopulator orders = this.pop.Tables[this.db.Orders];

            this.db.Orders.Rows.Add(orders.Generate());
            Console.WriteLine("AddOrder");
            this.Check();
        }
Exemplo n.º 7
0
 public void Remove(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.Remove(tablePopulator.Table);
 }
Exemplo n.º 8
0
 public UniqueValidatorCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulator = new WeakReference(tablePopulator);
 }
Exemplo n.º 9
0
 public void Add(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulators.Add(tablePopulator.Table.TableName, tablePopulator);
 }
Exemplo n.º 10
0
 public bool Contains(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     return(this.Contains(tablePopulator.Table));
 }
 public SqlCommandUniqueValidator(
     ITablePopulator table,
     UniqueConstraint unique,
     string connectionString
     )
     : base(table,unique,new SqlFactory(),connectionString)
 {
 }
 public UniqueValidatorBase(ITablePopulator table, UniqueConstraint unique)
 {
     if(table==null)
         throw new ArgumentNullException("table");
     if(unique==null)
         throw new ArgumentNullException("unique");
     this.table=new WeakReference(table);
     this.unique=unique;
 }
Exemplo n.º 13
0
        public void SetUp()
        {
            this.db  = new UserOrderProductDataSet();
            this.pop = new DatabasePopulator();
            this.pop.Populate(this.db);

            this.users         = this.pop.Tables[this.db.Tables["Users"]];
            this.orders        = this.pop.Tables[this.db.Tables["Orders"]];
            this.products      = this.pop.Tables[this.db.Tables["Products"]];
            this.orderProducts = this.pop.Tables[this.db.Tables["OrderProducts"]];
        }
Exemplo n.º 14
0
 public UniqueValidatorBase(ITablePopulator table, UniqueConstraint unique)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (unique == null)
     {
         throw new ArgumentNullException("unique");
     }
     this.table  = new WeakReference(table);
     this.unique = unique;
 }
 public DbCommandUniqueValidatorBase(
     ITablePopulator table,
     UniqueConstraint unique,
     IDbFactory dbFactory,
     string connectionString
     )
     : base(table,unique)
 {
     if (dbFactory == null)
         throw new ArgumentNullException("factory");
     if (connectionString == null)
         throw new ArgumentNullException("connectionString");
     this.dbFactory = dbFactory;
     this.connectionString = connectionString;
 }
Exemplo n.º 16
0
 public DbCommandUniqueValidatorBase(
     ITablePopulator table,
     UniqueConstraint unique,
     IDbFactory dbFactory,
     string connectionString
     )
     : base(table, unique)
 {
     if (dbFactory == null)
     {
         throw new ArgumentNullException("factory");
     }
     if (connectionString == null)
     {
         throw new ArgumentNullException("connectionString");
     }
     this.dbFactory        = dbFactory;
     this.connectionString = connectionString;
 }
        public ForeignKeyProviderBase(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
        {
            if (foreignTable == null)
                throw new ArgumentNullException("foreignTable");
            if (foreignKey == null)
                throw new ArgumentNullException("foreignKey");
            this.foreignTable = foreignTable;
            this.foreignKey = foreignKey;

            isNullable = true;
            foreach (DataColumn column in foreignKey.Columns)
            {
                if (!column.AllowDBNull)
                {
                    isNullable = false;
                    break;
                }
            }
        }
Exemplo n.º 18
0
        public ForeignKeyProviderBase(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
        {
            if (foreignTable == null)
            {
                throw new ArgumentNullException("foreignTable");
            }
            if (foreignKey == null)
            {
                throw new ArgumentNullException("foreignKey");
            }
            this.foreignTable = foreignTable;
            this.foreignKey   = foreignKey;

            isNullable = true;
            foreach (DataColumn column in foreignKey.Columns)
            {
                if (!column.AllowDBNull)
                {
                    isNullable = false;
                    break;
                }
            }
        }
Exemplo n.º 19
0
 public MethodUniqueValidator(ITablePopulator table, UniqueConstraint unique, MethodInfo method)
     : base(table, unique)
 {
     this.method = method;
 }
 public UniqueValidatorCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator==null)
         throw new ArgumentNullException("tablePopulator");
     this.tablePopulator=new WeakReference(tablePopulator);
 }
 public DictionaryUniqueValidator(ITablePopulator table, UniqueConstraint unique)
     : base(table,unique)
 {
 }
 public ForeignKeyProvider(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
     : base(foreignTable,foreignKey)
 {
 }
        public void SetUp()
        {
            this.db = new UserOrderProductDataSet();
            this.pop = new DatabasePopulator();
            this.pop.Populate(this.db);

            this.users=this.pop.Tables[this.db.Tables["Users"]];
            this.orders=this.pop.Tables[this.db.Tables["Orders"]];
            this.products=this.pop.Tables[this.db.Tables["Products"]];
            this.orderProducts=this.pop.Tables[this.db.Tables["OrderProducts"]];
        }
 public ForeignKeyProviderCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator==null)
         throw new ArgumentNullException("tablePopulator");
     this.tablePopulator=new WeakReference(tablePopulator);
 }
Exemplo n.º 25
0
 public ForeignKeyProvider(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
     : base(foreignTable, foreignKey)
 {
 }
Exemplo n.º 26
0
 public DictionaryUniqueValidator(ITablePopulator table, UniqueConstraint unique)
     : base(table, unique)
 {
 }