Example #1
0
        public void Should_Serialize_Doubles_In_Different_Cultures()
        {
            // TODO - fixup on mono, seems to throw inside double.parse
            // Given
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");

            var modelWithDoubleValues =
                new ModelWithDoubleValues
            {
                Latitude  = 50.933984,
                Longitude = 7.330627
            };

            var s          = new JavaScriptSerializer();
            var serialized = s.Serialize(modelWithDoubleValues);

            // When
            var deserializedModelWithDoubleValues = s.Deserialize <ModelWithDoubleValues>(serialized);

            // Then
            Assert.Equal(modelWithDoubleValues.Latitude, deserializedModelWithDoubleValues.Latitude);
            Assert.Equal(modelWithDoubleValues.Longitude, deserializedModelWithDoubleValues.Longitude);
        }