Skip to content

Conversion from TestCase string parameter to DateTimeOffset #3053

Description

@Thorarin

TestCaseAttribute includes behavior to perform conversion of some parameter types to the desired target type. Amongst others, conversion from String to DateTime and from String to TimeSpan are supported. This is useful, because no constants of these target types can be defined in the TestCaseAttribute.

It would be nice if DateTimeOffset could be added could be added to the list of supported conversions.

For example:

[TestCase("2018-10-09 15:15:00+02:00")]
public void MyTest(DateTimeOffset foo)
{
}

Convert.ChangeType does not appear to work for DateTimeOffset, so the code would be similar to the code for TimeSpan.

I wouldn't mind creating a PR for this if that helps; it seems fairly straightforward to add.

NUnit version: latest master

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions