Skip to content

TestCase and Values do not correctly convert DateTime string in current culture #2008

@morgen2009

Description

@morgen2009

Converting string into DateTime the TestCase, Values attributes use invariant culture System.Globalization.CultureInfo.InvariantCulture. I expect that when I change the TestExecutionContext.CurrentCulture using SetCultureAttribute for test / test fixture, the converter should use the new culture info. What do you think about?

The following tests fail

[TestCase("12.10.1942")]
[SetCulture("de-DE")]
public void CanConvertStringToDateTimeInCurrentCulture(DateTime dt)
{
     Assert.AreEqual(new DateTime(1942, 10, 12), dt);
}

[Test]
[SetCulture("de-DE")]
public void CanConvertStringToDateTimeInCurrentCulture([Values("12.10.1942")] DateTime dt)
{
     Assert.AreEqual(new DateTime(1942, 10, 12), dt);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions