Closed SeanFeldman closed 5 years ago
@nemakam please review
Marked PR as [WIP]
until it's not and ready to be merged.
@nemakam, et. al., what's the explanation for not throwing ArgumentException instead? Is it ease of the implementation of this library method? Most APIs I can think of which have some kind of "Send" method tend to throw if you tell it to send but don't give any data for sending. I feel like silently doing nothing might be hiding errors in the code calling this library.
If it's ease of implementation (like avoiding enumerating something twice) could something like this be done?
SendBatch(IEnumerable<Whatever> batch)
{
bool foundAny = false; // *****
foreach (Whatever w in batch)
{
foundAny = true; // *****
// ... Do something ...
}
if (!foundAny) { throw new ArgumentException("batch", "Batch contained no items"); } // *****
}
@dlstucki that was my initial take, but there was a compelling argument why an empty list should not throw: https://github.com/Azure/azure-service-bus-dotnet/issues/550#issuecomment-461330073
@dlstucki that was my initial take
@SeanFeldman Thanks! Seeing other APIs which behave this way makes me feel better.
The only reason this is still not merged is because I have no idea what would be a better way to test this behaviour w/o hitting the broker. If you have ideas @dlstucki, please share 🙂
@SeanFeldman, I haven't been following along very closely so I probably don't understand it. What do you need to verify in order to test this? Would this work?
@dlstucki that's sort of in place already.
I'll go with this for now and if a better test idea emerges, can be PR-ed
Fixes #550