views:

68

answers:

1

Is it possible to test Nullable Types with PersistenceSpecification?

var approved = new Nullable<DateTime>();
spec.CheckProperty(x => x.Approved, approved);

Currently this throws a NullReferenceException. Am I doing it wrong?

A: 

Is possible indeed.

  1. Is approved of type Nullable<DateTime>?
  2. Have you created your own IEqualityComparer?
  3. Could you provide some more code for us to help you?
mhenrixon
Yes, Approved is Nullable. Not using an IEqualityComparer implementation.
mxmissile
The problems with dates in .NET is that two date instances having the same value is not equal by default. Ex. date1 = '2009-01-01', date2 = '2009-01-01' but date1 != date2. Hence you need to implement your own IEqualityComparer so that you can compare the actual values inside the datetime like year, month and so on.
mhenrixon

related questions