Get tests working with different regional formatting
- fixes #1959, "[unit tests] 3 test failures with non-default long time format" - tests failed if system configured w/ non-default time formats - Linq expression constants were converted to strings using system culture - now converted using invariant culture
This commit is contained in:
Родитель
2c160ea866
Коммит
0d858916b2
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
@ -72,21 +73,24 @@ namespace System.Web.OData.Query.Expressions
|
|||
else
|
||||
{
|
||||
LinqParameterContainer container = node.Value as LinqParameterContainer;
|
||||
string stringValue;
|
||||
if (container != null)
|
||||
{
|
||||
string stringValue = container.Property as string;
|
||||
stringValue = container.Property as string;
|
||||
if (stringValue != null)
|
||||
{
|
||||
Out("\"" + stringValue + "\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
Out(container.Property.ToString());
|
||||
stringValue = String.Format(CultureInfo.InvariantCulture, "{0}", container.Property);
|
||||
Out(stringValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Out(node.Value.ToString());
|
||||
stringValue = String.Format(CultureInfo.InvariantCulture, "{0}", node.Value);
|
||||
Out(stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1520,7 +1520,7 @@ namespace System.Web.OData.Query.Expressions
|
|||
[InlineData("cast(null,Edm.Byte) ne 1", "$it => (null != Convert(1))")]
|
||||
[InlineData("cast(null,Edm.Guid) eq 00000000-0000-0000-0000-000000000000", "$it => (null == Convert(00000000-0000-0000-0000-000000000000))")]
|
||||
[InlineData("cast(null,Edm.String) ne '123'", "$it => (null != \"123\")")]
|
||||
[InlineData("cast(null,Edm.DateTimeOffset) eq 2001-01-01T12:00:00.000+08:00", "$it => (null == Convert(1/1/2001 12:00:00 PM +08:00))")]
|
||||
[InlineData("cast(null,Edm.DateTimeOffset) eq 2001-01-01T12:00:00.000+08:00", "$it => (null == Convert(01/01/2001 12:00:00 +08:00))")]
|
||||
[InlineData("cast(null,Edm.Duration) eq duration'P8DT23H59M59.9999S'", "$it => (null == Convert(8.23:59:59.9999000))")]
|
||||
[InlineData("cast(null,'Microsoft.TestCommon.Types.SimpleEnum') eq null", "$it => (null == null)")]
|
||||
[InlineData("cast(null,'Microsoft.TestCommon.Types.FlagsEnum') eq null", "$it => (null == null)")]
|
||||
|
@ -1676,7 +1676,7 @@ namespace System.Web.OData.Query.Expressions
|
|||
[InlineData("FloatProp eq @p", "1.23", "$it => ($it.FloatProp == 1.23)")]
|
||||
[InlineData("DoubleProp eq @p", "4.56", "$it => ($it.DoubleProp == Convert(4.56))")]
|
||||
[InlineData("StringProp eq @p", "'abc'", "$it => ($it.StringProp == \"abc\")")]
|
||||
[InlineData("DateTimeOffsetProp eq @p", "2001-01-01T12:00:00.000+08:00", "$it => ($it.DateTimeOffsetProp == 1/1/2001 12:00:00 PM +08:00)")]
|
||||
[InlineData("DateTimeOffsetProp eq @p", "2001-01-01T12:00:00.000+08:00", "$it => ($it.DateTimeOffsetProp == 01/01/2001 12:00:00 +08:00)")]
|
||||
[InlineData("TimeSpanProp eq @p", "duration'P8DT23H59M59.9999S'", "$it => ($it.TimeSpanProp == 8.23:59:59.9999000)")]
|
||||
[InlineData("GuidProp eq @p", "00000000-0000-0000-0000-000000000000", "$it => ($it.GuidProp == 00000000-0000-0000-0000-000000000000)")]
|
||||
[InlineData("SimpleEnumProp eq @p", "Microsoft.TestCommon.Types.SimpleEnum'First'", "$it => (Convert($it.SimpleEnumProp) == 0)")]
|
||||
|
@ -1698,7 +1698,7 @@ namespace System.Web.OData.Query.Expressions
|
|||
[InlineData("@p eq 1.23", "FloatProp", "$it => ($it.FloatProp == 1.23)")]
|
||||
[InlineData("@p eq 4.56", "NullableDoubleProp", "$it => ($it.NullableDoubleProp == Convert(4.56))")]
|
||||
[InlineData("@p eq 'abc'", "StringProp", "$it => ($it.StringProp == \"abc\")")]
|
||||
[InlineData("@p eq 2001-01-01T12:00:00.000+08:00", "DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp == 1/1/2001 12:00:00 PM +08:00)")]
|
||||
[InlineData("@p eq 2001-01-01T12:00:00.000+08:00", "DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp == 01/01/2001 12:00:00 +08:00)")]
|
||||
[InlineData("@p eq duration'P8DT23H59M59.9999S'", "TimeSpanProp", "$it => ($it.TimeSpanProp == 8.23:59:59.9999000)")]
|
||||
[InlineData("@p eq 00000000-0000-0000-0000-000000000000", "GuidProp", "$it => ($it.GuidProp == 00000000-0000-0000-0000-000000000000)")]
|
||||
[InlineData("@p eq Microsoft.TestCommon.Types.SimpleEnum'First'", "SimpleEnumProp", "$it => (Convert($it.SimpleEnumProp) == 0)")]
|
||||
|
|
Загрузка…
Ссылка в новой задаче