public void to_int16() { Assert.Throws <ArgumentNullException>(() => StringExtensions.ToInt16(null)); Assert.Throws <ArgumentException>(() => string.Empty.ToInt16()); const string Invalid = "invalid"; Assert.Equal(short.MaxValue, short.MaxValue.ToString(CultureInfo.InvariantCulture).ToInt16()); Assert.Throws <FormatException>(() => Invalid.ToInt16()); short result; Assert.True(short.MaxValue.ToString(CultureInfo.InvariantCulture).ToInt16(out result)); Assert.Equal(short.MaxValue, result); Assert.False(Invalid.ToInt16(out result)); Assert.Equal(default(short), result); }