ThisToThat/ThisToThatTests/ToInt16Tests.cs
/// <summary>
/// Makes multiple Int64 to nullable Int16 conversions and asserts that the results are correct.
/// </summary>
Makes multiple Int64 to nullable Int16 conversions and asserts that the results are correct.
Makes multiple Int64 to nullable Int16 conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToInt16 tests")]
        public void TestInt64ToInt16Nullable()
        {
            Int64 source = Int64.MinValue;
            Assert.IsInstanceOfType(source, typeof(Int64));
            Int16? result = source.ToInt16Nullable();
            Assert.IsNull(result);
            source = 42L;
            Assert.IsInstanceOfType(source, typeof(Int64));
            result = source.ToInt16Nullable();
            Assert.AreEqual((short)42, result);
            Assert.IsInstanceOfType(result, typeof(Int16));
            source = Int64.MaxValue;
            Assert.IsInstanceOfType(source, typeof(Int64));
            result = source.ToInt16Nullable();
            Assert.IsNull(result);
        }
[ TestMethod , TestCategory ( " " ) ] public void TestInt64ToInt16Nullable ( ) { Int64 source = Int64 . MinValue ; Assert . IsInstanceOfType ( source , typeof ( Int64 ) ) ; Int16 ? result = source . ToInt16Nullable ( ) ; Assert . IsNull ( result ) ; source = 42L ; Assert . IsInstanceOfType ( source , typeof ( Int64 ) ) ; result = source . ToInt16Nullable ( ) ; Assert . AreEqual ( ( short ) 42 , result ) ; Assert . IsInstanceOfType ( result , typeof ( Int16 ) ) ; source = Int64 . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( Int64 ) ) ; result = source . ToInt16Nullable ( ) ; Assert . IsNull ( result ) ; }
Makes multiple Int64 to nullable Int16 conversions and asserts that the results are correct.
Makes multiple Int64 to nullable Int16 conversions and asserts that the results are correct .
// Test conversion of source type minimum value // Here we would expect this conversion to fail (and return null),  // since the source type's minimum value (-9223372036854775808) is less than the target type's minimum value (-32768). // Test conversion of source type value 42 to target type // Test conversion of source type maximum value // Here we would expect this conversion to fail (and return null),  // since the source type's maximum value (9223372036854775807) is greater than the target type's maximum value (32767).