using System;
using System.Collections.Generic;
using System.Text;
[Serializable]
public class ColumnDataField
{
#region Fields
private int _columnIndex;
private string _dataFields;
#endregion Fields
#region Properties
/// <summary>
/// Column index
/// </summary>
public int ColumnIndex
{
get { return _columnIndex; }
set { _columnIndex = value; }
}
/// <summary>
/// Data fields
/// </summary>
public string DataFields
{
get { return _dataFields; }
set { _dataFields = value; }
}
/// <summary>
/// Convert DataFields string to data field list
/// </summary>
internal List<String> DataFieldList
{
get
{
if (string.IsNullOrWhiteSpace(DataFields)) return new List<String>();
string[] _array = DataFields.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
List<String> _fields = new List<String>(_array);
for (int _i = _fields.Count - 1; _i >= 0; _i--)
{
_fields[_i] = _fields[_i].Trim();
if (string.IsNullOrWhiteSpace(_fields[_i])) _fields.RemoveAt(_i);
}
return _fields;
}
set
{
StringBuilder _buffer = new StringBuilder();
foreach (string _field in value)
{
if (_buffer.Length > 0) _buffer.Append(",");
_buffer.Append(_field);
}
DataFields = _buffer.ToString();
}
}
#endregion Properties
}
}
I'm an intern unit testing in C# so go easy on me.
I haven't had too many problems with my other projects but I can't seem to figure out how I'm suppose to unit test the internal List.
This is the code that I have so far for my unit test:
[TestMethod]
public void DataFields_Test()
{
ColumnDataField questionText = new ColumnDataField();
questionText.DataFields = "test";
string expected = "test";
string actual = questionText.DataFields;
Assert.AreEqual(expected, actual);
}
So that will run the DataFields property but other than that it's not going over any of the other code. I've been searching online for days trying to figure out the best way to go about this. I don't need to be told exactly what to do but guidance would be greatly appreciated.