public void Constructor_ExpectedValues() { // Call var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Assert Assert.IsInstanceOf <TypeConverter>(converter); }
public void CanConvertTo_OtherTypeThanStringOrLoadSchematizationType_ReturnFalse() { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call bool canConvertToNonString = converter.CanConvertTo(typeof(object)); // Assert Assert.IsFalse(canConvertToNonString); }
public void CanConvertTo_LoadSchematizationType_ReturnTrue() { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call bool canConvertToString = converter.CanConvertTo(typeof(LoadSchematizationType)); // Assert Assert.IsTrue(canConvertToString); }
public void ConvertFrom_InvalidType_ThrowNotSupportedException() { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call TestDelegate call = () => converter.ConvertFrom(new object()); // Assert Assert.Throws <NotSupportedException>(call); }
public void ConvertTo_ForAllEnumValues_ReturnExpectedText(ConfigurationStabilityPointStructuresLoadSchematizationType value, string expectedText) { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call object result = converter.ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(string)); // Assert Assert.AreEqual(expectedText, result); }
public void ConvertFrom_Text_ReturnExpectedConfigurationStabilityPointStructuresLoadSchematizationType(string value, ConfigurationStabilityPointStructuresLoadSchematizationType expectedResult) { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call object result = converter.ConvertFrom(value); // Assert Assert.AreEqual(expectedResult, result); }
/// <summary> /// Writes the <paramref name="loadSchematizationType"/> in XML format to file. /// </summary> /// <param name="writer">The writer to use for writing.</param> /// <param name="loadSchematizationType">The calculation configuration 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="loadSchematizationType"/> cannot be performed.</exception> private static void WriteConfigurationLoadSchematizationTypeWhenAvailable(XmlWriter writer, ConfigurationStabilityPointStructuresLoadSchematizationType?loadSchematizationType) { if (!loadSchematizationType.HasValue) { return; } var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); writer.WriteElementString(StabilityPointStructuresConfigurationSchemaIdentifiers.LoadSchematizationTypeElement, converter.ConvertToInvariantString(loadSchematizationType.Value)); }
public void ConvertTo_InvalidType_ThrowNotSupportedException() { // Setup var random = new Random(21); var invalidValue = random.NextEnumValue <ConfigurationStabilityPointStructuresLoadSchematizationType>(); var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); // Call TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(object)); // Assert Assert.Throws <NotSupportedException>(call); }
public void ConvertFrom_InvalidText_ThrowNotSupportedException() { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); const string invalidValue = "some text"; // Call TestDelegate call = () => converter.ConvertFrom(invalidValue); // Assert string message = Assert.Throws <NotSupportedException>(call).Message; Assert.AreEqual($"Value '{invalidValue}' is not supported.", message); }
public void ConvertFrom_InvalidLoadSchematizationType_ThrowInvalidEnumArgumentException() { // Setup var converter = new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter(); const LoadSchematizationType invalidValue = (LoadSchematizationType)983; // Call TestDelegate call = () => converter.ConvertFrom(invalidValue); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(LoadSchematizationType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }