Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date and numbers fail in different timezones/locales #211

Closed
SteveDunn opened this issue Aug 23, 2022 · 2 comments · Fixed by #215
Closed

Date and numbers fail in different timezones/locales #211

SteveDunn opened this issue Aug 23, 2022 · 2 comments · Fixed by #215
Labels
bug Something isn't working

Comments

@SteveDunn
Copy link
Owner

Describe the bug

Date related tests do not pass in a different timezone/locale

Steps to reproduce

Run the tests in a different timezone/locale

Expected behaviour

They pass

@SteveDunn SteveDunn added the bug Something isn't working label Aug 23, 2022
@Herdo
Copy link
Contributor

Herdo commented Aug 25, 2022

  • Some DateTimeOffset and DateTime tests seem to fail due to a different time zone, e.g.:
    Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
  • Some float tests seem to fail due to a different decimal separator character depending on the current culture, e.g.:
    Expected: 123,45 --> Actual: 12345

List of failing tests, 55 in total:

tests (55 tests) Failed: 55 tests failed
  MediumTests (55 tests) Failed: 55 tests failed
    Vogen.IntegrationTests.SerializationAndConversionTests (55 tests) Failed: 55 tests failed
      ClassVos (15 tests) Failed: 15 tests failed
        DateTimeOffsetVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        FloatVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
      RecordClassVos (15 tests) Failed: 15 tests failed
        DateTimeOffsetVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        FloatVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
      RecordStructVos (15 tests) Failed: 15 tests failed
        DateTimeOffsetVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        FloatVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
        FloatVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "123.45") Failed: Assert.Equal() Failure
      StructVos (10 tests) Failed: 10 tests failed
        DateTimeOffsetVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeOffsetVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          WhenDapperValueConverterUsesValueConverter Failed: Expected actual to be 15.01.2022 19:08:49 +00:00, but found 15.01.2022 19:08:49 +01:00.
        DateTimeVoTests (net6.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net5.0) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp3.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (netcoreapp2.1) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure
        DateTimeVoTests (net461) (1 test) Failed: One or more child tests failed: 1 test failed
          TypeConverter_CanConvertToAndFrom (1 test) Failed: One or more child tests failed: 1 test failed
            TypeConverter_CanConvertToAndFrom(value: "2022-01-15T19:08:49.5413764+00:00") Failed: Assert.Equal() Failure

@SteveDunn
Copy link
Owner Author

We needed some CultureInfo.InvariantCultures sprinking around the conversions in the code.

One other issue that was found when fixing was the following code showed that there's no dapper converter from decimal to a VO with an underlying type of decimal, e.g.

            var parameters = new { Value = 123.45f };
            IEnumerable<DapperDecimalVo> results = await connection.QueryAsync<DapperDecimalVo>("SELECT @Value", parameters);

The Parse method that's generated has this:

            public override DapperDecimalVo Parse(object value)
            {
                return value switch
                {
                    global::System.Int32 intValue => DapperDecimalVo.Deserialize(intValue),
                    global::System.Int64 longValue when longValue < global::System.Int32.MaxValue => DapperDecimalVo.Deserialize((global::System.Int32)longValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Decimal.TryParse(stringValue, out var result) => DapperDecimalVo.Deserialize(result),
                    _ => throw new global::System.InvalidCastException($"Unable to cast object of type {value.GetType()} to DapperDecimalVo"),
                };
            }

We need to add the primitive itself into the switch expression.

@SteveDunn SteveDunn changed the title Date related tests do not pass in a different timezone/locale Date and numbers fail in different timezones/locales Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants