diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-02-18 07:05:03 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-18 07:05:03 -0600 |
| commit | fccc9c6440af11fd400f3d1dee243d2d18ea1651 (patch) | |
| tree | 0ba68479205c192e630c985f5025c67d2ca4c715 /tests/slskd.Tests.Unit/TestOptionsMonitor.cs | |
| parent | dee1b7315ff56194f7868803b876cabe4ab165d7 (diff) | |
| parent | 58e865993eb507e31dca3771fac0ea3829880d02 (diff) | |
| download | slskd-fccc9c6440af11fd400f3d1dee243d2d18ea1651.tar.gz | |
Merge pull request #346 from slskd/groups
Add upload slot and bandwidth limiting for user groups
Diffstat (limited to 'tests/slskd.Tests.Unit/TestOptionsMonitor.cs')
| -rw-r--r-- | tests/slskd.Tests.Unit/TestOptionsMonitor.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/slskd.Tests.Unit/TestOptionsMonitor.cs b/tests/slskd.Tests.Unit/TestOptionsMonitor.cs new file mode 100644 index 00000000..6c16adf5 --- /dev/null +++ b/tests/slskd.Tests.Unit/TestOptionsMonitor.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.Extensions.Options; +using Moq; + +namespace slskd.Tests.Unit +{ + public class TestOptionsMonitor<TOptions> : IOptionsMonitor<TOptions> + { + private Action<TOptions, string> _listener; + + public TestOptionsMonitor(TOptions currentValue) + { + CurrentValue = currentValue; + } + + public TOptions CurrentValue { get; private set; } + + public TOptions Get(string name) + { + return CurrentValue; + } + + public void Set(TOptions value) + { + CurrentValue = value; + _listener.Invoke(value, null); + } + + public IDisposable OnChange(Action<TOptions, string> listener) + { + _listener = listener; + return new Mock<IDisposable>().Object; + } + + public void RaiseOnChange(TOptions options) + { + _listener(options, null); + } + } +} |
