-
Notifications
You must be signed in to change notification settings - Fork 13
feat(ServiceBus): adds unit tests #197
base: master
Are you sure you want to change the base?
Conversation
0b8c6e7
to
79207fa
Compare
Hey @guilhermeluizsp could I get your input here? There's a test failing in this PR - it seems that the DLR is failing to resolve (bind) to a property of a dynamic type. Do you have any idea why? What am I missing? |
@bruno-brant Yeah. The We can either make it public to make the binder work correctly, or create a custom |
@guilhermeluizsp huh, would've never guessed that was the problem, but surely it's simple enough, I will make the class public. |
79207fa
to
ba0c280
Compare
ba0c280
to
ef51b64
Compare
1aa2ac3
to
f4899e4
Compare
228d2e5
to
00dd8d3
Compare
04a2848
to
e00db1a
Compare
@bruno-brant I was supposed to review this PR a long time ago, I'm really sorry for that. May you please rebase with the master branch (so I can begin to review it)? I'm seeing things from previous PRs that were merged already. |
Oh, no worries, it is still work in progress. You are correct, I probably need to work some git magic here, because I've rebased a number of branches after branching this one... I will do this shortly. I do want your opinion. I was unable to do testing on ServiceBus without refactoring it, at least a little. And there's a dirty hack on a test that you'll probably despise, but I believe we can live with it until we rewrite this class / the whole LightWorker approach. |
ec09746
to
d78e58e
Compare
9263657
to
2c8d7b1
Compare
ILightTelemetry lacked the TrackException method. This was done by design - to avoid consumer code to call TrackException, it seems, because exception handling was supposed to be done at framework level. Our take is that this creates more problems than solves. Consumers will still be able to directly use LightTelemetry if they desire, or handle the exception and NOT call TrackException when they should. Also, that meant a lot of violations of LSP in the framework code, and led to numerous issues during testing since it was impossible to mockout the LightTelemetry.TrackEvent dependency. This commit adds the method and removes all LSP violations that I could find. Closes #159.
Coverage is now above 90%.
Added some tests that should test the general behavior of ServiceBus.
Parallel tests results in concurrency on Workbench (add vs reset).
2c8d7b1
to
fa1142e
Compare
/// <returns> | ||
/// The current configuration for a service bus. | ||
/// </returns> | ||
ServiceBusConfiguration GetConfiguration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both GetConfiguration
and GetConfiguration(string connectionName)
will basically do the same thing. I was wondering if we could keep just GetConfiguration(string connectionName)
and create an extension method for GetConfiguration()
that routes to GetConfiguration(string.Empty)
, and the implementation takes care of how do handle it (just like Microsoft's IHttpClientFactory
does). What do you think?
@@ -60,7 +162,7 @@ private string GetConnection<T>(KeyValuePair<MethodInfo, T> item) | |||
public Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs) | |||
{ | |||
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code) | |||
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exceptionReceivedEventArgs.Exception); | |||
Workbench.Instance.Telemetry.TrackException(exceptionReceivedEventArgs.Exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that's the standard we'd like to use, but ServiceBus
inherits from LightWorker
, which already have a Telemetry
property that points exactly to Workbench.Instance.Telemetry
. Do you think we should use it or perhaps it is too much of nitpicking of me?
@@ -96,7 +198,7 @@ public void ProcessQueue() | |||
{ | |||
Exception moreInfo = new Exception($"Exception reading message from queue {queueName}. See inner exception for details. Message={exRegister.Message}", exRegister); | |||
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code) | |||
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(moreInfo); | |||
Workbench.Instance.Telemetry.TrackException(moreInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here about the Telemetry
property from LightWorker
.
@@ -114,7 +216,7 @@ public void ProcessQueue() | |||
{ | |||
Exception moreInfo = new Exception($"Error setting up queue consumption from service bus. See inner exception for details. Message={exception.Message}", exception); | |||
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code) | |||
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(moreInfo); | |||
Workbench.Instance.Telemetry.TrackException(moreInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
@@ -155,7 +260,7 @@ private void ProcessSubscription() | |||
{ | |||
Exception moreInfo = new Exception($"Exception reading message from topic {topicName} and subscriptName {subscriptName}. See inner exception for details. Message={exRegister.Message}", exRegister); | |||
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code) | |||
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(moreInfo); | |||
Workbench.Instance.Telemetry.TrackException(moreInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
@@ -200,13 +305,57 @@ private void ProcessSubscription() | |||
{ | |||
Exception moreInfo = new Exception($"Error setting up subscription consumption from service bus. See inner exception for details. Message={exception.Message}", exception); | |||
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code) | |||
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(moreInfo); | |||
Workbench.Instance.Telemetry.TrackException(moreInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also here.
Should only be approved after #217 and #210.