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