1

Closed

[LOC] LogCommand_logs_command_text_and_parameters test failed with hungarian culture

description

System.Data.Entity.Infrastructure.DbCommandLoggerTests+LogCommand.LogCommand_logs_command_text_and_parameters: Assert.Equal() Failure
Position: First difference is at position 13
Expected: -- Param2: '7.7' (Type = Decimal, Direction = InputOutput, IsNullable = false, Size = -1, Precision = 18, Scale = 2)
Actual: -- Param2: '7,7' (Type = Decimal, Direction = InputOutput, IsNullable = false, Size = -1, Precision = 18, Scale = 2)
at System.Data.Entity.Infrastructure.DbCommandLoggerTests.LogCommand.LogCommand_logs_command_text_and_parameters() in DbCommandLoggerTests.cs:line 359


In DbCommandLogger LogParameter method the parameter.Value should be converted to string with invatiant culture (currently line 285):
.Append((parameter.Value == null || parameter.Value == DBNull.Value) ? "null" : parameter.Value.ToString(CultureInfo.InvariantCulture))
Closed May 29, 2013 at 5:30 PM by mgirgin

comments

ajcvickers wrote May 28, 2013 at 11:06 PM

I'm in the code so I'll try to fix.

ajcvickers wrote May 29, 2013 at 4:41 PM

Fixed in b1b4ac75a14b

ZoningIn (Add timezone info to DbCommandLogger output per design meeting decision)

The code uses DateTimeOffset.Now instead of DateTime.Now. The tests didn't need to change because they are written in such a way as to not depend on the format of the DateTime output, but I did manual verification that the output now looks like:

SELECT TOP (2)
[c].[Id] AS [Id],
[c].[Title] AS [Title]
FROM [dbo].[Blogs] AS [c]
-- Executing at 5/28/2013 4:10:48 PM -07:00
-- Completed in 1 ms with result: SqlDataReader

I also fixed CodePlex 1160 "LogCommand_logs_command_text_and_parameters test failed with Hungarian culture" while I was in the code. The fix is to use current culture to format the decimal value in the expected string for the Assert.