diff options
| author | Kenneth Cochran <kenneth.cochran@gmail.com> | 2024-11-30 06:08:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-30 12:08:19 +0100 |
| commit | e922fe8582fca1b0204d5bdc35adeed55844d648 (patch) | |
| tree | 78378aef9da71be393165a2214698e1b8c9996d5 | |
| parent | 556f4c4bfbf915eec3b1b9983f1c132916281b67 (diff) | |
Added test for ListsingsManager.DeleteListingsProvider(). (#12793)
* Added test for DeleteListingsProvider().
* Added myself to CONTRIBUTORS.md
* Removed unintentionally committed test SaveListingProvider_SavesProviderAndReturnsInfo()
* Cleaned up test in response to PR feedback.
| -rw-r--r-- | CONTRIBUTORS.md | 1 | ||||
| -rw-r--r-- | tests/Jellyfin.LiveTv.Tests/Listings/ListingsManagerTests.cs | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e44608135..eccc3b0ce 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -192,6 +192,7 @@ - [jaina heartles](https://github.com/heartles) - [oxixes](https://github.com/oxixes) - [elfalem](https://github.com/elfalem) + - [Kenneth Cochran](https://github.com/kennethcochran) - [benedikt257](https://github.com/benedikt257) - [revam](https://github.com/revam) diff --git a/tests/Jellyfin.LiveTv.Tests/Listings/ListingsManagerTests.cs b/tests/Jellyfin.LiveTv.Tests/Listings/ListingsManagerTests.cs new file mode 100644 index 000000000..40934d9c6 --- /dev/null +++ b/tests/Jellyfin.LiveTv.Tests/Listings/ListingsManagerTests.cs @@ -0,0 +1,50 @@ +using System; +using Jellyfin.LiveTv.Configuration; +using Jellyfin.LiveTv.Listings; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.LiveTv; +using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; +using Moq; +using Xunit; + +namespace Jellyfin.LiveTv.Tests.Listings; + +public class ListingsManagerTests +{ + private readonly IConfigurationManager _config; + private readonly IListingsProvider[] _listingsProviders; + private readonly ILogger<ListingsManager> _logger; + private readonly ITaskManager _taskManager; + private readonly ITunerHostManager _tunerHostManager; + + public ListingsManagerTests() + { + _logger = Mock.Of<ILogger<ListingsManager>>(); + _config = Mock.Of<IConfigurationManager>(); + _taskManager = Mock.Of<ITaskManager>(); + _tunerHostManager = Mock.Of<ITunerHostManager>(); + _listingsProviders = new[] { Mock.Of<IListingsProvider>() }; + } + + [Fact] + public void DeleteListingsProvider_DeletesProvider() + { + // Arrange + var id = "MockId"; + var manager = new ListingsManager(_logger, _config, _taskManager, _tunerHostManager, _listingsProviders); + + Mock.Get(_config) + .Setup(x => x.GetConfiguration(It.IsAny<string>())) + .Returns(new LiveTvOptions { ListingProviders = [new ListingsProviderInfo { Id = id }] }); + + // Act + manager.DeleteListingsProvider(id); + + // Assert + Assert.DoesNotContain( + _config.GetLiveTvConfiguration().ListingProviders, + p => p.Id.Equals(id, StringComparison.Ordinal)); + } +} |
