Ejemplo n.º 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 EulerAngles3F(new [] { 1.1f, 2.2f, 3.3f }, EulerAngleOrder.XYZ);

                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;
            }
        }
Ejemplo n.º 2
0
 private void TestToStringResults(EulerAngles3F o, string s, string listSeparator, string decimalSeparator)
 {
     string[] results = s.Split(new[] { listSeparator }, StringSplitOptions.RemoveEmptyEntries);
     Assert.AreEqual(results.Length, 4);
     Assert.True(results[0].Contains(decimalSeparator));
     Assert.True(results[1].Contains(decimalSeparator));
     Assert.True(results[2].Contains(decimalSeparator));
     Assert.AreEqual(float.Parse(results[0]), o.Angles.X);
     Assert.AreEqual(float.Parse(results[1]), o.Angles.Y);
     Assert.AreEqual(float.Parse(results[2]), o.Angles.Z);
 }