public static void Constructor_ExpectedValues() { // Call var converter = new AngleValueConverter(); // Assert Assert.That(converter, Is.InstanceOf <IValueConverter>()); Assert.That(converter.IsDegrees, Is.False); }
public void ConvertBack_WithNonDoubleValueType_ReturnsNull(object value) { // Setup var converter = new AngleValueConverter(); // Call object result = converter.ConvertBack(value, typeof(Angle), null, null); // Assert Assert.That(result, Is.Null); }
public void ConvertIsDegreesFalse_WithValidValueAndDutchCulture_ReturnsExpectedTargetValue(double value, string expectedValue) { // Setup Angle angleToConvert = Angle.FromRadians(value); var converter = new AngleValueConverter(); // Call object result = converter.Convert(angleToConvert, targetType, null, null); // Assert Assert.That(result, Is.EqualTo(expectedValue)); }
public void ConvertBackIsDegreesFalse_WithAngleValueType_ReturnsExpectedResult(string value, double expectedResult) { // Setup var converter = new AngleValueConverter(); // Call object result = converter.ConvertBack(value, typeof(Angle), null, null); // Assert var convertedResult = (Angle)result; Assert.That(convertedResult.Radians, Is.EqualTo(expectedResult).Within(1e-5)); }
public void Convert_WithUnsupportedValue_ThrowsNotSupportedException(object unsupportedValue) { // Setup var converter = new AngleValueConverter(); // Call TestDelegate call = () => converter.Convert(unsupportedValue, typeof(string), null, null); // Assert string expectedMessage = $"Conversion from {unsupportedValue?.GetType().Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }
public void ConvertBack_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var converter = new AngleValueConverter(); Type unsupportedType = typeof(object); // Call TestDelegate call = () => converter.ConvertBack("1", unsupportedType, null, null); // Assert string expectedMessage = $"Conversion to {unsupportedType.Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }
public void Convert_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var random = new Random(21); Angle valueToConvert = random.NextAngle(); var converter = new AngleValueConverter(); Type unsupportedType = typeof(int); // Call TestDelegate call = () => converter.Convert(valueToConvert, unsupportedType, null, null); // Assert string expectedMessage = $"Conversion to {unsupportedType.Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }