コード例 #1
0
        public void ToInt32Test()
        {
            string strValue = string.Empty; // TODO: 初始化为适当的值
            int    expected = 0;            // TODO: 初始化为适当的值
            int    actual;

            actual = ConvertString.ToInt32(strValue);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strFormat"></param>
        public VersionInfo(string strFormat)
        {
            try
            {
                strFormat = strFormat.ToLower();

                int iIndexOf1 = strFormat.IndexOf('.');
                int iIndexOf2 = strFormat.IndexOf('.', iIndexOf1 + 1);
                int iIndexOf3 = iIndexOf2 + 1;

                while (iIndexOf3 < strFormat.Length && Char.IsDigit(strFormat, iIndexOf3))
                {
                    iIndexOf3++;
                }

                m_Major    = ConvertString.ToInt32(strFormat.Substring(0, iIndexOf1));
                m_Minor    = ConvertString.ToInt32(strFormat.Substring(iIndexOf1 + 1, iIndexOf2 - iIndexOf1 - 1));
                m_Revision = ConvertString.ToInt32(strFormat.Substring(iIndexOf2 + 1, iIndexOf3 - iIndexOf2 - 1));

                if (iIndexOf3 < strFormat.Length && !Char.IsWhiteSpace(strFormat, iIndexOf3))
                {
                    m_Patch = (strFormat[iIndexOf3] - 'a') + 1;
                }
                else
                {
                    m_Patch = 0;
                }

                m_SourceString = strFormat;
            }
            catch
            {
                m_Major        = 0;
                m_Minor        = 0;
                m_Revision     = 0;
                m_Patch        = 0;
                m_SourceString = string.Empty;
            }
        }