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

CODE RUB: ShouldThrowValidationExceptionOnModifyIfCreatedAndUpdatedDatesAreSameAndLogItAsync #571

Open
mtoncic opened this issue Oct 21, 2021 · 1 comment
Labels

Comments

@mtoncic
Copy link
Contributor

mtoncic commented Oct 21, 2021

Student randomStudent = CreateRandomStudent();
DateTimeOffset sameDate = randomStudent.CreatedDate;
Student invalidStudent = randomStudent;
invalidStudent.CreatedDate = sameDate;
invalidStudent.UpdatedDate = sameDate;

I believe this can be simplified.
Instead of these lines we can just write:

Student randomStudent = CreateRandomStudent();
Student invalidStudent = randomStudent;

Since we're using CreateRandomStudent it will fill all the needed properties. And it sets the same date both for CreatedDate and UpdatedDate.

Or to make it explicit:

  DateTimeOffset createdAndUpdatedDate = DateTimeOffset.UtcNow;
  Student randomStudent= CreateRandomStudent(dates: createdAndUpdatedDate);
  Student invalidStudent = randomStudent;
@kandarpgautam
Copy link

kandarpgautam commented Feb 12, 2024

This can be closed as the commit f9d1b91 passes this test. another closing remark in #811 about randomizing datetime, Here date time does not need to be random as there is a validation that requires UpdatedDate to be recent. Though this seems faulty as if we are using Message Queue, processing of Modification of record might not take place within bounds of what we define as recent (i.e. 1 minute), In this case, it will throw validation error. I may be wrong but let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants