ThisToThat/ThisToThatTests/ToUInt64Tests.cs
/// <summary>
/// Makes multiple Int16 to UInt64 or default conversions and asserts that the results are correct.
/// </summary>
Makes multiple Int16 to UInt64 or default conversions and asserts that the results are correct.
Makes multiple Int16 to UInt64 or default conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToUInt64 tests")]
        public void TestInt16ToUInt64OrDefault()
        {
            Int16 source = Int16.MinValue;
            Assert.IsInstanceOfType(source, typeof(Int16));
            UInt64? result = source.ToUInt64OrDefault(86UL);
            Assert.AreEqual(86UL, result);
            Assert.IsInstanceOfType(result, typeof(UInt64));
            source = (short)42;
            Assert.IsInstanceOfType(source, typeof(Int16));
            result = source.ToUInt64OrDefault(86UL);
            Assert.AreEqual(42UL, result);
            Assert.IsInstanceOfType(result, typeof(UInt64));
            source = Int16.MaxValue;
            Assert.IsInstanceOfType(source, typeof(Int16));
            result = source.ToUInt64OrDefault(86UL);
            Assert.AreEqual(32767UL, result);
            Assert.IsInstanceOfType(result, typeof(UInt64));
        }
[ TestMethod , TestCategory ( " " ) ] public void TestInt16ToUInt64OrDefault ( ) { Int16 source = Int16 . MinValue ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; UInt64 ? result = source . ToUInt64OrDefault ( 86UL ) ; Assert . AreEqual ( 86UL , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt64 ) ) ; source = ( short ) 42 ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; result = source . ToUInt64OrDefault ( 86UL ) ; Assert . AreEqual ( 42UL , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt64 ) ) ; source = Int16 . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( Int16 ) ) ; result = source . ToUInt64OrDefault ( 86UL ) ; Assert . AreEqual ( 32767UL , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt64 ) ) ; }
Makes multiple Int16 to UInt64 or default conversions and asserts that the results are correct.
Makes multiple Int16 to UInt64 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 86UL),  // since the source type's minimum value (-32768) 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