public void Assert_fails_if_any_constraint_fails() { const string TestValue = "Hello World"; var sut = new AllConstraint( Does.StartWith("foo").IgnoreCase, // will fail Does.EndWith("world").IgnoreCase ); Assert.That(() => Assert.That(TestValue, sut), Throws.Exception); }
public void Assert_succeeds_if_all_constraints_are_met() { const string TestValue = "Hello World"; var sut = new AllConstraint( Does.StartWith("hello").IgnoreCase, Does.EndWith("world").IgnoreCase ); Assert.That(TestValue, sut); }
public void Assert_succeeds_if_all_constraints_are_met(object testValue, IConstraint[] constraints) { foreach (var constraint in constraints) { Mock.Get(constraint).Setup(p => p.ApplyTo(testValue)).Returns(new ConstraintResult(constraint, testValue, ConstraintStatus.Success)); } var sut = new AllConstraint(constraints); Assert.That(testValue, sut); }
public void Assert_checks_all_constraints(object testValue, IConstraint[] constraints) { foreach (var constraint in constraints) { Mock.Get(constraint).Setup(p => p.ApplyTo(testValue)).Returns(new ConstraintResult(constraint, testValue, ConstraintStatus.Success)).Verifiable(); } var sut = new AllConstraint(constraints); Assert.That(testValue, sut); foreach (var constraint in constraints) { Mock.Get(constraint).Verify(p => p.ApplyTo(testValue)); } }
/// <summary> /// 获取单表的数据字段信息 /// </summary> /// <param name="TableName">表名称</param> /// <returns></returns> public IList <IDataTableColumn> ReadColumns(string TableName) { string SQL = @"SELECT table_name, column_name, data_type, data_length, data_precision, data_scale, nullable, data_default FROM user_tab_columns WHERE lower(table_name) = :tableName ORDER BY column_id"; IDataParameter para2 = m_DBHelper.DbAdapter.CreateParameter(":tableName", TableName.ToLower()); DataSet ds = m_DBHelper.ExecuteQuery(SQL, para2); Hashtable hs = GetColumnComment(TableName); if (ds != null && ds.Tables[0].Rows.Count > 0) { IList <IDataTableColumn> list = new List <IDataTableColumn>(); //唯一的自增值 bool isGenerated = true; foreach (DataRow row in ds.Tables[0].Rows) { IDataTableColumn Col = new DataTableColumn(); Col.SimpleType = "0"; //默认的公共类型 Col.ColumnName = Convert.ToString(row["column_name"]); Col.Nullable = Convert.ToString(row["nullable"]) == "Y"; Col.TableName = TableName; Col.TableSchema = TableName; Col.DefaultValue = Convert.ToString(row["data_default"]); Col.Type = Convert.ToString(row["data_type"]); Col.FullType = Col.Type; string odata_length = Convert.ToString(row["data_length"]); string odata_precision = Convert.ToString(row["data_precision"]); string odata_scale = Convert.ToString(row["data_scale"]); int x = 0; if (Int32.TryParse(odata_length, out x)) { Col.Length = x; } if (Int32.TryParse(odata_precision, out x)) { Col.Precision = x; } if (Int32.TryParse(odata_scale, out x)) { Col.Scale = x; } DataRow[] rows = AllConstraint.Select(String.Format("table_name='{0}' AND column_name='{1}' AND constraint_type='P'", TableName, Col.ColumnName)); if (rows != null && rows.Length > 0) { Col.PrimaryKey = true; if (Col.Type == "NUMBER" || Col.Type == "INTEGER") { /* * //针对需要触发器字段的特殊处理 * if (Col.TableName.ToUpper().Equals("TMPLABELTODBFIELD") || * Col.TableName.ToUpper().Equals("UPFILESLIST") || * Col.TableName.ToUpper().Equals("CASEMATERIALLIST") || * Col.TableName.ToUpper().Equals("FLOW_DEPOIST") || * Col.TableName.ToUpper().Equals("FLOW_HOLIDAY") || * Col.TableName.ToUpper().Equals("FLOW_INSTANCE_LOG") || * Col.TableName.ToUpper().Equals("FLOW_USER_HISTORY") || * Col.TableName.ToUpper().Equals("SYSPAGETOOLS")) * * Col.Generated = true; */ if (this.IsHaveSequenceOra(Col.TableName) && isGenerated) { Col.Generated = true; isGenerated = false; } } } if (hs != null && hs[Col.ColumnName] != null)//注释 { Col.Comment = hs[Col.ColumnName].ToString(); } list.Add(Col); } return(list); } return(null); }