ThisToThat/ThisToThatTests/ToSByteTests.cs
/// <summary>
/// Makes multiple Int32 to nullable SByte conversions and asserts that the results are correct.
/// </summary>
Makes multiple Int32 to nullable SByte conversions and asserts that the results are correct.
Makes multiple Int32 to nullable SByte conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToSByte tests")]
        public void TestInt32ToSByteNullable()
        {
            Int32 source = Int32.MinValue;
            Assert.IsInstanceOfType(source, typeof(Int32));
            SByte? result = source.ToSByteNullable();
            Assert.IsNull(result);
            source = 42;
            Assert.IsInstanceOfType(source, typeof(Int32));
            result = source.ToSByteNullable();
            Assert.AreEqual((sbyte)42, result);
            Assert.IsInstanceOfType(result, typeof(SByte));
            source = Int32.MaxValue;
            Assert.IsInstanceOfType(source, typeof(Int32));
            result = source.ToSByteNullable();
            Assert.IsNull(result);
        }
[ TestMethod , TestCategory ( " " ) ] public void TestInt32ToSByteNullable ( ) { Int32 source = Int32 . MinValue ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; SByte ? result = source . ToSByteNullable ( ) ; Assert . IsNull ( result ) ; source = 42 ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; result = source . ToSByteNullable ( ) ; Assert . AreEqual ( ( sbyte ) 42 , result ) ; Assert . IsInstanceOfType ( result , typeof ( SByte ) ) ; source = Int32 . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; result = source . ToSByteNullable ( ) ; Assert . IsNull ( result ) ; }
Makes multiple Int32 to nullable SByte conversions and asserts that the results are correct.
Makes multiple Int32 to nullable SByte 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 (-2147483648) 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 null),  // since the source type's maximum value (2147483647) is greater than the target type's maximum value (127).