ThisToThat/ThisToThatTests/ToUInt32Tests.cs
/// <summary>
/// Makes multiple Int32 to nullable UInt32 conversions and asserts that the results are correct.
/// </summary>
Makes multiple Int32 to nullable UInt32 conversions and asserts that the results are correct.
Makes multiple Int32 to nullable UInt32 conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToUInt32 tests")]
        public void TestInt32ToUInt32Nullable()
        {
            Int32 source = Int32.MinValue;
            Assert.IsInstanceOfType(source, typeof(Int32));
            UInt32? result = source.ToUInt32Nullable();
            Assert.IsNull(result);
            source = 42;
            Assert.IsInstanceOfType(source, typeof(Int32));
            result = source.ToUInt32Nullable();
            Assert.AreEqual(42u, result);
            Assert.IsInstanceOfType(result, typeof(UInt32));
            source = Int32.MaxValue;
            Assert.IsInstanceOfType(source, typeof(Int32));
            result = source.ToUInt32Nullable();
            Assert.AreEqual(2147483647u, result);
            Assert.IsInstanceOfType(result, typeof(UInt32));
        }
[ TestMethod , TestCategory ( " " ) ] public void TestInt32ToUInt32Nullable ( ) { Int32 source = Int32 . MinValue ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; UInt32 ? result = source . ToUInt32Nullable ( ) ; Assert . IsNull ( result ) ; source = 42 ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; result = source . ToUInt32Nullable ( ) ; Assert . AreEqual ( 42u , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt32 ) ) ; source = Int32 . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( Int32 ) ) ; result = source . ToUInt32Nullable ( ) ; Assert . AreEqual ( 2147483647u , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt32 ) ) ; }
Makes multiple Int32 to nullable UInt32 conversions and asserts that the results are correct.
Makes multiple Int32 to nullable UInt32 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 (0). // Test conversion of source type value 42 to target type // Test conversion of source type maximum value