ThisToThat/ThisToThatTests/ToSByteTests.cs
/// <summary>
/// Makes multiple Int16 to SByte or default conversions and asserts that the results are correct.
/// </summary>
Makes multiple Int16 to SByte or default conversions and asserts that the results are correct.
Makes multiple Int16 to SByte or default conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToSByte tests")]
        public void TestInt16ToSByteOrDefault()
        {
            Int16 source = Int16.MinValue;
            Assert.IsInstanceOfType(source, typeof(Int16));
            SByte? result = source.ToSByteOrDefault((sbyte)86);
            Assert.AreEqual((sbyte)86, result);
            Assert.IsInstanceOfType(result, typeof(SByte));
            source = (short)42;
            Assert.IsInstanceOfType(source, typeof(Int16));
            result = source.ToSByteOrDefault((sbyte)86);
            Assert.AreEqual((sbyte)42, result);
            Assert.IsInstanceOfType(result, typeof(SByte));
            source = Int16.MaxValue;
            Assert.IsInstanceOfType(source, typeof(Int16));
            result = source.ToSByteOrDefault((sbyte)86);
            Assert.AreEqual((sbyte)86, result);
            Assert.IsInstanceOfType(result, typeof(SByte));
        }
[ TestMethod , TestCategory ( " " ) ] public void TestInt16ToSByteOrDefault ( ) { Int16 source = Int16 . MinValue ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; SByte ? result = source . ToSByteOrDefault ( ( sbyte ) 86 ) ; Assert . AreEqual ( ( sbyte ) 86 , result ) ; Assert . IsInstanceOfType ( result , typeof ( SByte ) ) ; source = ( short ) 42 ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; result = source . ToSByteOrDefault ( ( sbyte ) 86 ) ; Assert . AreEqual ( ( sbyte ) 42 , result ) ; Assert . IsInstanceOfType ( result , typeof ( SByte ) ) ; source = Int16 . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; result = source . ToSByteOrDefault ( ( sbyte ) 86 ) ; Assert . AreEqual ( ( sbyte ) 86 , result ) ; Assert . IsInstanceOfType ( result , typeof ( SByte ) ) ; }
Makes multiple Int16 to SByte or default conversions and asserts that the results are correct.
Makes multiple Int16 to SByte or default 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 the default value of (sbyte)86),  // since the source type's minimum value (-32768) is less than the target type's minimum value (-128). // 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 the default value of (sbyte)86),  // since the source type's maximum value (32767) is greater than the target type's maximum value (127).