public void Constructor_ExpectedValues() { // Call var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Assert Assert.IsInstanceOf <TypeConverter>(converter); }
public void CanConvertTo_OtherType_ReturnFalse() { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call bool canConvertTo = converter.CanConvertTo(typeof(object)); // Assert Assert.IsFalse(canConvertTo); }
public void CanConvertTo_WaveConditionsInputStepSize_ReturnTrue() { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call bool canConvertTo = converter.CanConvertTo(typeof(WaveConditionsInputStepSize)); // Assert Assert.IsTrue(canConvertTo); }
public void ConvertFrom_InvalidDoubleValue_ThrowNotSupportedException(double value) { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call TestDelegate call = () => converter.ConvertFrom(value); // Assert Assert.Throws <NotSupportedException>(call); }
public void ConvertFrom_Null_ThrowNotSupportedException() { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call TestDelegate call = () => converter.ConvertFrom(null); // Assert Assert.Throws <NotSupportedException>(call); }
public void CanConvertFrom_NullableDouble_ReturnTrue() { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call bool canConvertFrom = converter.CanConvertFrom(typeof(double?)); // Assert Assert.IsTrue(canConvertFrom); }
public void ConvertTo_ValidConfigurationWaveConditionsInputStepSize_ReturnExpectedText( ConfigurationWaveConditionsInputStepSize value, string expectedText) { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call object convertTo = converter.ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(string)); // Assert Assert.AreEqual(expectedText, convertTo); }
public void ConvertFrom_ValidWaveConditionsInputStepSize_ReturnConfigurationWaveConditionsInputStepSize( WaveConditionsInputStepSize value, ConfigurationWaveConditionsInputStepSize expectedResult) { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call object convertFrom = converter.ConvertFrom(value); // Assert Assert.AreEqual(expectedResult, convertFrom); }
public void ConvertFrom_ValidDoubleValue_ReturnWaveConditionsInputStepSize( double value, ConfigurationWaveConditionsInputStepSize expectedResult) { // Setup var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call object convertFrom = converter.ConvertFrom(null, CultureInfo.CurrentCulture, value); // Assert Assert.AreEqual(expectedResult, convertFrom); }
public void ConvertTo_Object_ThrowNotSupportedException() { // Setup var random = new Random(21); var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call TestDelegate call = () => converter.ConvertTo(random.NextEnumValue <ConfigurationWaveConditionsInputStepSize>(), typeof(object)); // Assert Assert.Throws <NotSupportedException>(call); }
/// <summary> /// Writes the <paramref name="stepSize"/> in XML format to file. /// </summary> /// <param name="writer">The writer to use for writing.</param> /// <param name="stepSize">The stepsize to write.</param> /// <exception cref="InvalidOperationException">Thrown when the <paramref name="writer"/> /// is closed.</exception> /// <exception cref="NotSupportedException">Thrown when the conversion /// of <paramref name="stepSize"/> cannot be performed.</exception> private static void WriteConfigurationWaveConditionsInputStepSizeWhenAvailable( XmlWriter writer, ConfigurationWaveConditionsInputStepSize?stepSize) { if (!stepSize.HasValue) { return; } var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); writer.WriteElementString(WaveConditionsCalculationConfigurationSchemaIdentifiers.StepSize, converter.ConvertToInvariantString(stepSize.Value)); }
public void ConvertFrom_InvalidWaveConditionsInputStepSize_ThrowInvalidEnumArgumentException() { // Setup const WaveConditionsInputStepSize invalidValue = (WaveConditionsInputStepSize)9999; var converter = new ConfigurationWaveConditionsInputStepSizeConverter(); // Call TestDelegate call = () => converter.ConvertFrom(invalidValue); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(WaveConditionsInputStepSize)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }