Ejemplo n.º 1
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Assert
            Assert.IsInstanceOf <TypeConverter>(converter);
        }
Ejemplo n.º 2
0
        public void CanConvertTo_OtherType_ReturnFalse()
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            bool canConvertTo = converter.CanConvertTo(typeof(object));

            // Assert
            Assert.IsFalse(canConvertTo);
        }
Ejemplo n.º 3
0
        public void CanConvertTo_StabilityStoneCoverWaveConditionsCalculationType_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            bool canConvertTo = converter.CanConvertTo(typeof(StabilityStoneCoverWaveConditionsCalculationType));

            // Assert
            Assert.IsTrue(canConvertTo);
        }
Ejemplo n.º 4
0
        public void ConvertFrom_Null_ThrowNotSupportedException()
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertFrom(null);

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
Ejemplo n.º 5
0
        public void CanConvertFrom_String_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            bool canConvertFrom = converter.CanConvertFrom(typeof(string));

            // Assert
            Assert.IsTrue(canConvertFrom);
        }
Ejemplo n.º 6
0
        public void ConvertFrom_ValidStabilityStoneCoverWaveConditionsCalculationType_ReturnConfigurationStabilityStoneCoverCalculationType(
            StabilityStoneCoverWaveConditionsCalculationType originalValue, ConfigurationStabilityStoneCoverCalculationType expectedValue)
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            object convertedValue = converter.ConvertFrom(originalValue);

            // Assert
            Assert.AreEqual(expectedValue, convertedValue);
        }
Ejemplo n.º 7
0
        public void ConvertTo_ValidConfigurationStabilityStoneCoverCalculationType_ReturnExpectedText(
            ConfigurationStabilityStoneCoverCalculationType originalValue, string expectedText)
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            object calculationType = converter.ConvertTo(null, CultureInfo.CurrentCulture, originalValue, typeof(string));

            // Assert
            Assert.AreEqual(expectedText, calculationType);
        }
Ejemplo n.º 8
0
        public void ConvertTo_ValidConfigurationStabilityStoneCoverCalculationType_ReturnStabilityStoneCoverWaveConditionsCalculationType(
            ConfigurationStabilityStoneCoverCalculationType originalValue, StabilityStoneCoverWaveConditionsCalculationType expectedResult)
        {
            // Setup
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            object calculationType = converter.ConvertTo(null, CultureInfo.CurrentCulture, originalValue, typeof(StabilityStoneCoverWaveConditionsCalculationType));

            // Assert
            Assert.AreEqual(expectedResult, calculationType);
        }
        protected override void WriteWaveConditionsSpecificParameters(XmlWriter writer, StabilityStoneCoverWaveConditionsCalculationConfiguration configuration)
        {
            if (!configuration.CalculationType.HasValue)
            {
                return;
            }

            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            writer.WriteElementString(WaveConditionsCalculationConfigurationSchemaIdentifiers.CalculationType,
                                      converter.ConvertToInvariantString(configuration.CalculationType.Value));
        }
Ejemplo n.º 10
0
        public void ConvertTo_InvalidConfigurationStabilityStoneCoverCalculationType_ThrowInvalidEnumArgumentException(Type destinationType)
        {
            // Setup
            const StabilityStoneCoverWaveConditionsCalculationType invalidValue = (StabilityStoneCoverWaveConditionsCalculationType)99;
            var converter = new ConfigurationStabilityStoneCoverCalculationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertTo(invalidValue, destinationType);

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationStabilityStoneCoverCalculationType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage);
        }