public void ChangeType_ReturnsNullIfTypeAllowsNulls() { // Act var actual = CommandLineUtility.ChangeType(null, typeof(int?)); // Assert Assert.IsNull(actual); }
public void ChangeType_ReturnsConvertedTypeWhenThereIsAConverterFromTheType() { // Act var actual = CommandLineUtility.ChangeType("3", typeof(int)); // Assert Assert.AreEqual(typeof(int), actual.GetType()); Assert.AreEqual(3, actual); }
public void ChangeType_ReturnsValueIfTypesMatch() { // Act var actual = CommandLineUtility.ChangeType(3, typeof(int)); // Assert Assert.AreEqual(typeof(int), actual.GetType()); Assert.AreEqual(3, actual); }
public void ChangeType_ThrowsIfTypeDoesNotAllowNulls() { // Act & Assert ExceptionAssert.Throws <InvalidCastException>(() => CommandLineUtility.ChangeType(null, typeof(int))); }
public void ChangeType_ThrowsIfTypeIsNull() { // Act & Assert ExceptionAssert.ThrowsArgNull(() => CommandLineUtility.ChangeType(new object(), null), "type"); }
public void ChangeType_ThrowWhenThereIsNoConverterForEither() { // Act & Assert ExceptionAssert.Throws <InvalidOperationException>(() => CommandLineUtility.ChangeType(false, typeof(MockClass))); }