对象引用未设置为单元测试中对象c#的实例

时间:2015-05-15 08:18:14

标签: c# unit-testing tdd

我正在测试 LoadDieArchtCD 的方法,

public void LoadDieArchtCDTest()
    {
        UtilityBL target = new UtilityBL(); // TODO: Initialize to an appropriate value
        DataSet objDS = new DataSet(); // TODO: Initialize to an appropriate value
        string dataTableName = "DieArchtCD"; // TODO: Initialize to an appropriate value
        DataTable actual;
        actual = target.LoadDieArchtCD(objDS, dataTableName);
        Assert.IsNotNull(actual, "No DieArchtCD loaded");

    }

LoadDieArchtCD 的内部代码 UtilityBL.cs

public DataTable LoadDieArchtCD(DataSet objDS, String dataTableName)
    {
        // UtilityDL utilDL = new UtilityDL();
        UtilityADL utilDL = (UtilityADL)TypeProvider.CreateDL("UtilityDL");
        utilDL.LoadDieArchtCD(objDS, dataTableName);

        // Check if there is any data return
        if (objDS.Tables[dataTableName].Rows.Count <= 0)
            throw new ApplicationException("There are no Die Architecture Code setup in the database");
        return objDS.Tables[dataTableName]; //ERROR OCCUR HERE
    }

深入了解 objDS.Tables [dataTableName]

public override void LoadDieArchtCD(System.Data.DataSet Ds, string DataTableName)
    {
        Ds.Clear();
        Ds.AcceptChanges();
        Ds.ReadXml(@"..\\..\\..\\TestBusinessLogic\\UtilityDLLoadDieArchtCDFilter.xml");
    }

有针对DieArchtCD的数据表和行数据的数据集。

<DieArchitectureCode>
<DieArchtCodeName>test</DieArchtCodeName>
</DieArchitectureCode>

错误发生在UtilityBL.cs文件中,但是我无法在那里更改业务逻辑。我应该在哪里纠正以摆脱错误?

0 个答案:

没有答案