-
Notifications
You must be signed in to change notification settings - Fork 287
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
refactor TransmissionPolicy #2311
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5c07597
refactor TransmissionPolicy
TimothyMothra 5db7401
fix
TimothyMothra 0c47ba8
typo
TimothyMothra d2fb8c2
fix
TimothyMothra c397077
fix
TimothyMothra bf52489
new tests
TimothyMothra 0cfbef0
Merge branch 'develop' into tilee/refactor_transmissionpolicy
TimothyMothra 60317c2
cleanup
TimothyMothra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/Helpers/StubTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...icationLifecycleTransmissionPolicyTest.cs → ...icationLifecycleTransmissionPolicyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...metryChannel.Tests/Implementation/TransmissionPolicy/TransmissionPolicyCollectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.TransmissionPolicy | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
[TestCategory("TransmissionPolicy")] | ||
public class TransmissionPolicyCollectionTests | ||
{ | ||
[TestMethod] | ||
public void VerifyCalcuateMinimums() | ||
{ | ||
// Setup | ||
var policies = new TransmissionPolicyCollection(policies: new List<TransmissionPolicy> | ||
{ | ||
new MockValueTransmissionPolicy(maxSenderCapacity: null, maxBufferCapacity: null, maxStorageCapacity: null), | ||
new MockValueTransmissionPolicy(maxSenderCapacity: 1, maxBufferCapacity: 2, maxStorageCapacity: 3), | ||
new MockValueTransmissionPolicy(maxSenderCapacity: 101, maxBufferCapacity: 102, maxStorageCapacity: 103), | ||
}); | ||
|
||
// Act & Verify | ||
Assert.AreEqual(1, policies.CalculateMinimumMaxSenderCapacity()); | ||
Assert.AreEqual(2, policies.CalculateMinimumMaxBufferCapacity()); | ||
Assert.AreEqual(3, policies.CalculateMinimumMaxStorageCapacity()); | ||
} | ||
|
||
|
||
[TestMethod] | ||
public void VerifyCalcuateMinimums_CanHandleNulls() | ||
{ | ||
// Setup | ||
var policies = new TransmissionPolicyCollection(policies: new List<TransmissionPolicy> | ||
{ | ||
new MockValueTransmissionPolicy(maxSenderCapacity: null, maxBufferCapacity: null, maxStorageCapacity: null), | ||
}); | ||
|
||
// Act & Verify | ||
Assert.AreEqual(null, policies.CalculateMinimumMaxSenderCapacity()); | ||
Assert.AreEqual(null, policies.CalculateMinimumMaxBufferCapacity()); | ||
Assert.AreEqual(null, policies.CalculateMinimumMaxStorageCapacity()); | ||
} | ||
|
||
private class MockValueTransmissionPolicy : TransmissionPolicy | ||
{ | ||
public MockValueTransmissionPolicy(int? maxSenderCapacity, int? maxBufferCapacity, int? maxStorageCapacity) | ||
{ | ||
this.MaxSenderCapacity = maxSenderCapacity; | ||
this.MaxBufferCapacity = maxBufferCapacity; | ||
this.MaxStorageCapacity = maxStorageCapacity; | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../Implementation/TransmissionPolicyTest.cs → ...nsmissionPolicy/TransmissionPolicyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ApplicationLifecycleTransmissionPolicy.cs → ...ApplicationLifecycleTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tation/ErrorHandlingTransmissionPolicy.cs → ...Policy/ErrorHandlingTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../NetworkAvailabilityTransmissionPolicy.cs → .../NetworkAvailabilityTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ation/PartialSuccessTransmissionPolicy.cs → ...olicy/PartialSuccessTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mentation/ThrottlingTransmissionPolicy.cs → ...ionPolicy/ThrottlingTransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nnel/Implementation/TransmissionPolicy.cs → .../TransmissionPolicy/TransmissionPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
dont think its really worthy as these are internals anyway.
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.
We have 5 classes that inherit TransmissionPolicy. (I'm adding a 6th in my new PR).
I had a hard time finding the existing clrasses because they were all in the root.
I've moved them all to a unique subfolder and updated the namespace to match.