コード例 #1
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Assert
            Assert.IsInstanceOf <TypeConverter>(converter);
        }
コード例 #2
0
        public void CanConvertTo_OtherThanStringOrBreakWaterType_ReturnFalse()
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

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

            // Assert
            Assert.IsFalse(canConvertToString);
        }
コード例 #3
0
        public void CanConvertTo_BreakWaterType_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Call
            bool canConvertToString = converter.CanConvertTo(typeof(BreakWaterType));

            // Assert
            Assert.IsTrue(canConvertToString);
        }
コード例 #4
0
        public void ConvertFrom_InvalidText_ThrowNotSupportedException()
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

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

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
コード例 #5
0
        public void CanConvertFrom_String_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

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

            // Assert
            Assert.IsTrue(canConvertFromString);
        }
コード例 #6
0
        public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value,
                                                              string expectedResult)
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Call
            object result = converter.ConvertTo(value, typeof(string));

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
コード例 #7
0
        public void ConvertFrom_BreakWaterType_ReturnExpectedBreakWaterType(BreakWaterType value,
                                                                            ConfigurationBreakWaterType expectedResult)
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Call
            object result = converter.ConvertFrom(value);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
コード例 #8
0
        public void ConvertTo_InvalidDestinationType_ThrowsNotSupportedException()
        {
            // Setup
            var random    = new Random(21);
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertTo(random.NextEnumValue <ConfigurationBreakWaterType>(), typeof(object));

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
コード例 #9
0
        public void ConvertFrom_InvalidClosingStructureInflowModelType_ThrowInvalidEnumArgumentException()
        {
            // Setup
            const int invalidValue = -1;
            var       converter    = new ConfigurationBreakWaterTypeConverter();

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

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(BreakWaterType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }
コード例 #10
0
        public void ConvertTo_InvalidBreakWaterType_ThrowInvalidEnumArgumentException(Type destinationType)
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();
            const ConfigurationBreakWaterType invalidValue = (ConfigurationBreakWaterType)99999999;

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

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationBreakWaterType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }