ThisToThat/ThisToThatTests/ToUInt32Tests.cs
/// <summary>
/// Makes multiple SByte to UInt32 or default conversions and asserts that the results are correct.
/// </summary>
Makes multiple SByte to UInt32 or default conversions and asserts that the results are correct.
Makes multiple SByte to UInt32 or default conversions and asserts that the results are correct .
[TestMethod, TestCategory("ToUInt32 tests")]
        public void TestSByteToUInt32OrDefault()
        {
            SByte source = SByte.MinValue;
            Assert.IsInstanceOfType(source, typeof(SByte));
            UInt32? result = source.ToUInt32OrDefault(86u);
            Assert.AreEqual(86u, result);
            Assert.IsInstanceOfType(result, typeof(UInt32));
            source = (sbyte)42;
            Assert.IsInstanceOfType(source, typeof(SByte));
            result = source.ToUInt32OrDefault(86u);
            Assert.AreEqual(42u, result);
            Assert.IsInstanceOfType(result, typeof(UInt32));
            source = SByte.MaxValue;
            Assert.IsInstanceOfType(source, typeof(SByte));
            result = source.ToUInt32OrDefault(86u);
            Assert.AreEqual(127u, result);
            Assert.IsInstanceOfType(result, typeof(UInt32));
        }
[ TestMethod , TestCategory ( " " ) ] public void TestSByteToUInt32OrDefault ( ) { SByte source = SByte . MinValue ; Assert . IsInstanceOfType ( source , typeof ( SByte ) ) ; UInt32 ? result = source . ToUInt32OrDefault ( 86u ) ; Assert . AreEqual ( 86u , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt32 ) ) ; source = ( sbyte ) 42 ; Assert . IsInstanceOfType ( source , typeof ( SByte ) ) ; result = source . ToUInt32OrDefault ( 86u ) ; Assert . AreEqual ( 42u , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt32 ) ) ; source = SByte . MaxValue ; Assert . IsInstanceOfType ( source , typeof ( SByte ) ) ; result = source . ToUInt32OrDefault ( 86u ) ; Assert . AreEqual ( 127u , result ) ; Assert . IsInstanceOfType ( result , typeof ( UInt32 ) ) ; }
Makes multiple SByte to UInt32 or default conversions and asserts that the results are correct.
Makes multiple SByte to UInt32 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 86u),  // since the source type's minimum value (-128) 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