Example #1
0
        public void CanConvert_FloatType_True()
        {
            // arrange
            FloatValueConverter converter = new FloatValueConverter();
            FloatType           type      = new FloatType();

            // act
            bool result = converter.CanConvert(type);

            // assert
            Assert.True(result);
        }
Example #2
0
        public void Convert_Null_NullableFloat()
        {
            // arrange
            FloatValueConverter converter = new FloatValueConverter();
            FloatType           type      = new FloatType();

            float?expectedOutput = default(float?);

            // act
            bool result = converter.TryConvert(
                typeof(double), typeof(float?),
                null, out object convertedValue);

            // assert
            Assert.True(result);
            Assert.Equal(expectedOutput, convertedValue);
        }
Example #3
0
        public void Convert_Double_Float()
        {
            // arrange
            FloatValueConverter converter = new FloatValueConverter();
            FloatType           type      = new FloatType();
            double input          = 1.0f;
            float  expectedOutput = 1.0f;

            // act
            bool result = converter.TryConvert(
                typeof(double), typeof(float),
                input, out object convertedValue);

            // assert
            Assert.True(result);
            Assert.IsType <float>(convertedValue);
            Assert.Equal(expectedOutput, convertedValue);
        }