示例#1
0
        private void TestToStringWithCulture(CultureInfo culture)
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = culture;
            try
            {
                string listSeparator = culture.TextInfo.ListSeparator;
                string decimalSeparator = culture.NumberFormat.NumberDecimalSeparator;
                var o = new Polygon3F( new []
                {
                    new Vec3F(1.1f, 2.2f, 3.3f), 
                    new Vec3F(4.4f, 5.5f, 6.6f), 
                    new Vec3F(7.7f, 8.8f, 9.9f)
                });

                string s = o.ToString(null, null);
                TestToStringResults(o, s, listSeparator, decimalSeparator);

                string s2 = o.ToString();
                Assert.AreEqual(s, s2);

                s = o.ToString("G", culture);
                TestToStringResults(o, s, listSeparator, decimalSeparator);

                s = o.ToString("R", culture);
                TestToStringResults(o, s, listSeparator, decimalSeparator);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
示例#2
0
 private void TestToStringResults(Polygon3F o, string s, string listSeparator, string decimalSeparator)
 {
     string[] results = s.Split(new[] { listSeparator,"(",")" }, StringSplitOptions.RemoveEmptyEntries);
     Assert.AreEqual(results.Length, 1 + 9);
     Assert.True(results[1].Contains(decimalSeparator));//spot check that floats have correct decimal points
     Assert.AreEqual(float.Parse(results[1]), o.Vertices[0].X);
     Assert.AreEqual(float.Parse(results[2]), o.Vertices[0].Y);
     Assert.AreEqual(float.Parse(results[3]), o.Vertices[0].Z);
 }