Make NotificationResponse.Equals work with pre-compiled responses
We use NotificationResponse.Equals in our tests to compare actual and expected responses. This works for existing methods, but since pre-compiled responses don't contain template or content existing .Equals implementation fails when trying to compare attributes of null.
We could get rid of the .Equals and compare attributes with expected values in tests, but the methods are already part of the public interface and removing them is a breaking change.
Alternatively, we could add another response class for pre-compiled letters, but it's hard to fit it into existing class hierarchy (since it defines fewer fields than NotificationResponse it should either be a base class for it or both should derive from a common base class).
To avoid these changes we move the comparison logic to underlying attribute classes and use both == (to compare null values) and .Equals when comparing attributes. This keeps the existing behaviour of NotificationResponse.Equals while allowing us to instantiate LetterNotificationResponse with only pre-compiled fields set.
Add a sendPrecompiledLetterNotification method
The method accepts an array of bytes instead of a stream/file-like object since the easiest way to read an entire file in .NET seems to be File.ReadAllBytes, which returns byte[].
Add documentation for SendPrecompiledLetter
Add CHANGELOG record for new changes
Checklist
[x] I’ve used the pull request template
[x] I’ve written unit tests for these changes
[x] I’ve update the documentation (in README.md, CHANGELOG.md and CONTRIBUTING.md)
[ ] I’ve bumped the version number (in src/Notify/Notify.csproj)
Make NotificationResponse.Equals work with pre-compiled responses
We use
NotificationResponse.Equals
in our tests to compare actual and expected responses. This works for existing methods, but since pre-compiled responses don't containtemplate
orcontent
existing.Equals
implementation fails when trying to compare attributes ofnull
.We could get rid of the
.Equals
and compare attributes with expected values in tests, but the methods are already part of the public interface and removing them is a breaking change.Alternatively, we could add another response class for pre-compiled letters, but it's hard to fit it into existing class hierarchy (since it defines fewer fields than NotificationResponse it should either be a base class for it or both should derive from a common base class).
To avoid these changes we move the comparison logic to underlying attribute classes and use both
==
(to comparenull
values) and.Equals
when comparing attributes. This keeps the existing behaviour ofNotificationResponse.Equals
while allowing us to instantiateLetterNotificationResponse
with only pre-compiled fields set.Add a sendPrecompiledLetterNotification method
The method accepts an array of bytes instead of a stream/file-like object since the easiest way to read an entire file in .NET seems to be
File.ReadAllBytes
, which returnsbyte[]
.Add documentation for SendPrecompiledLetter
Add CHANGELOG record for new changes
Checklist
README.md, CHANGELOG.md and CONTRIBUTING.md
)src/Notify/Notify.csproj
)