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

Nullable DateTime deserialization issue #972

Closed
pieceofsummer opened this issue Aug 18, 2017 · 1 comment
Closed

Nullable DateTime deserialization issue #972

pieceofsummer opened this issue Aug 18, 2017 · 1 comment

Comments

@pieceofsummer
Copy link
Contributor

[Fact]
public void Deserialize_CorrectlyDeserializes_NullableDateTime()
{
    var value = DateTime.Now;
    var serializedData = new InvocationData(
        typeof(InvocationDataFacts).AssemblyQualifiedName,
        nameof(NullableDateTimeMethod),
        JobHelper.ToJson(new[] { typeof(DateTime?) }),
        JobHelper.ToJson(new[] { value.ToString("o", CultureInfo.InvariantCulture) }));

    var job = serializedData.Deserialize(); // throws
    
    Assert.Equal(value, job.Args[0]);
}

or even simpler:

[Fact]
public void Deserialize_CorrectlyDeserializes_NullableDateTime()
{
    var value = DateTime.Now;
    var job = Job.FromExpression(() => NullableDateTimeMethod(value));
    var invocationData = InvocationData.Serialize(job);

    var job2 = invocationData.Deserialize(); // throws

    Assert.Equal(value, job2.Args[0]);
}
@plaisted
Copy link
Contributor

Was just working on DateTime for #971 , might as well through this fix in as well.

plaisted added a commit to plaisted/Hangfire that referenced this issue Aug 18, 2017
@odinserj odinserj added this to the Hangfire 1.6.16 milestone Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants