예제 #1
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

            // Assert
            Assert.IsInstanceOf <TypeConverter>(converter);
        }
예제 #2
0
        public void CanConvertTo_OtherType_ReturnFalse()
        {
            // Setup
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

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

            // Assert
            Assert.IsFalse(canConvertTo);
        }
예제 #3
0
        public void CanConvertTo_WaveConditionsInputStepSize_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

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

            // Assert
            Assert.IsTrue(canConvertTo);
        }
예제 #4
0
        public void ConvertFrom_InvalidDoubleValue_ThrowNotSupportedException(double value)
        {
            // Setup
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

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

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
예제 #5
0
        public void ConvertFrom_Null_ThrowNotSupportedException()
        {
            // Setup
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

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

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
예제 #6
0
        public void CanConvertFrom_NullableDouble_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationWaveConditionsInputStepSizeConverter();

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

            // Assert
            Assert.IsTrue(canConvertFrom);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        /// <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));
        }
예제 #12
0
        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);
        }