public void CellIsEmpty_ReturnsDefaultValue() { //SETUP var sut = new CellDataParser(); //TEST var result = sut.Parse(typeof(string), string.Empty); //VALIDATE Assert.That(result, Is.EqualTo(string.Empty)); }
public void CellIsNull_ReturnsDefaultValue() { //SETUP var sut = new CellDataParser(); //TEST var result = sut.Parse(typeof(int), null); //VALIDATE Assert.That(result, Is.EqualTo(default(int))); }
public void InstancePropertyTypeIsNull_ThrowsArgumentNullException() { //SETUP var sut = new CellDataParser(); //TEST void TestDelegate() => sut.Parse(null, string.Empty); //VALIDATE Assert.Throws <ArgumentNullException>(TestDelegate); }
public void TypeIsNotSupport_ThrowsInvalidOperationException() { //SETUP var cellData = _fixture.Create <string>(); var sut = new CellDataParser(); //TEST void TestDelegate() => sut.Parse(typeof(UnitTestItem), cellData); //VALIDATE Assert.Throws <InvalidOperationException>(TestDelegate); }
public void CellHasValidData_ReturnsValueAsString() { //SETUP var cellValue = _fixture.Create <string>(); var cellValueAsString = cellValue.ToString(); var sut = new CellDataParser(); //TEST var result = sut.Parse(typeof(string), cellValueAsString); //VALIDATE Assert.That(result, Is.EqualTo(cellValue)); }
public void CellHasInvalidData_ThrowsInvalidOperationException() { //SETUP var cellValueAsString = _fixture.Create <string>(); var sut = new CellDataParser(); //TEST void TestDelegate() => sut.Parse(typeof(int), cellValueAsString); //VALIDATE var ex = Assert.Throws <InvalidOperationException>(TestDelegate); Assert.That(ex.Message, Is.EqualTo($"Could not parse value '{cellValueAsString}' to {typeof(int).Name}")); }