Will Unit Test add value to this DAL provider example beyond the integration test?

public List<int> GetPortfolioList()
{
    using (var connection = new SqlConnection("<connectionString>"))
    using (var command = new SqlCommand("SELECT * FROM Portfolio", connection))
    {
        connection.Open();
        var portfolioTable = SqlHelper.GetDataTable(command);
        var portfolios = from DataRow row
                            in portfolioTable.Rows
                            select int.Parse(row["Portfolio"].ToString());

        return portfolios.ToList();
    }
}

Take this method in the SQL DAL provider to get a list of portfolios as the name (and code) suggests. Since the database table for integration testing contains a fairly static data set, we can argue against several expectations. for example, the Portfolio List will: - not be empty - contain certain known values ​​- do not contain duplicates

- , ( ), . , , , , , , unit test . - ?

+3
4

, db ( ), linq sql ( linq ) .

, , / . ( , , "SELECT * FROM" , SQL , linq, , SQL Server, , linq .

, Linq SQL

, linq-, .

, , [ "" ]. ToString() NULL, , 2?

, nunit - , , , .

+4

Linq - , .

- ( Linq) - linq , .

, .

+3

, , "unit test" DAL, . , , , . ; , , .

, , , DAL .

+2

, , unit test, .

unit test , , .

e: The exceptional cases mentioned above in MathewMartin would be the only things that I would consider appropriate in this scenario.

+1
source

Source: https://habr.com/ru/post/1784144/


All Articles