【发布时间】:2014-12-11 07:28:38
【问题描述】:
我在“AddEffectiveQuarterTest”方法的单元测试中遇到错误。如何将属性设置为 true 以允许我插入空值?
AvailabilityBLTest.cs 文件:“AddEffectiveQuarterTest”方法
public void AddEffectiveQuarterTest()
{
AvailabilityBL target = new AvailabilityBL();
AvailabilityDS ds = new AvailabilityDS();
TestBusinessLogic.BusinessLogic_AvailabilityBLAccessor accessor = new TestBusinessLogic.BusinessLogic_AvailabilityBLAccessor(target);
// SETUP STANDARD TEST DATA
this.SetupTestData(ds, null);
int newModelID = -1;
.........
}
可用性DS.Designer.cs 文件
public string QuarterDisplay {
get {
try {
return ((string)(this[this.tableTime.QuarterDisplayColumn]));
}
catch (global::System.InvalidCastException e) {
throw new global::System.Data.StrongTypingException("The value for column \'QuarterDisplay\' in table \'Time\' is DBNull.", e);
}
}
set {
this[this.tableTime.QuarterDisplayColumn] = value;
}
}
如何使用以下代码进行编辑以将属性设置为 true 以允许我插入空值?
public bool AllowDBNull { get; set; }
如何检查 dbnull?我收到以下代码的错误。
public bool IsColumnNameNull() {
return this.IsNull(this.tableColumn.ColumnNameColumn);
}
public string SetColumnKeyNull() {
{
get
{
try
{
return ((string)(this[this.tableColumn.ColumnKeyColumn]));
}
catch (global::System.InvalidCastException e)
{
throw new global::System.Data.StrongTypingException("The value for column \'SetColumnKeyNull\' in table \'Column\' is DBNull.", e);
}
}
set
{
this[this.tableColumn.ColumnKeyColumn] = value;
}
}
【问题讨论】:
-
格式化你的代码....
-
清楚地阐述场景。
-
我已经对这些进行了更多的编辑和阐述,这里是详细信息stackoverflow.com/questions/27396648/…
标签: c# unit-testing dbnull