From 13324cac14059043ad12d5850012947572d612cf Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 12 Aug 2016 14:41:34 +0100 Subject: [PATCH] More unit tests around the login and also the core Plex Checker --- PlexRequests.Core/CacheKeys.cs | 6 - .../PlexAvailabilityCheckerTests.cs | 204 +++- .../PlexRequests.Services.Tests.csproj | 1 + .../Jobs/PlexAvailabilityChecker.cs | 7 +- PlexRequests.UI.Tests/UserLoginModuleTests.cs | 937 +++++++++--------- PlexRequests.UI/Modules/SearchModule.cs | 1 + PlexRequests.UI/Modules/UserLoginModule.cs | 2 +- 7 files changed, 690 insertions(+), 468 deletions(-) diff --git a/PlexRequests.Core/CacheKeys.cs b/PlexRequests.Core/CacheKeys.cs index 230da7971..0f718f1f1 100644 --- a/PlexRequests.Core/CacheKeys.cs +++ b/PlexRequests.Core/CacheKeys.cs @@ -35,20 +35,14 @@ namespace PlexRequests.Core public const string PlexLibaries = nameof(PlexLibaries); public const string PlexEpisodes = nameof(PlexEpisodes); - public const string TvDbToken = nameof(TvDbToken); - public const string SonarrQualityProfiles = nameof(SonarrQualityProfiles); public const string SonarrQueued = nameof(SonarrQueued); - public const string SickRageQualityProfiles = nameof(SickRageQualityProfiles); public const string SickRageQueued = nameof(SickRageQueued); - public const string CouchPotatoQualityProfiles = nameof(CouchPotatoQualityProfiles); public const string CouchPotatoQueued = nameof(CouchPotatoQueued); - public const string GetPlexRequestSettings = nameof(GetPlexRequestSettings); - public const string LastestProductVersion = nameof(LastestProductVersion); } } \ No newline at end of file diff --git a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs index abe90364c..e9c86a6c6 100644 --- a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs +++ b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs @@ -25,26 +25,35 @@ // ************************************************************************/ #endregion using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Threading.Tasks; using Moq; using NUnit.Framework; using PlexRequests.Api.Interfaces; +using PlexRequests.Api.Models.Plex; using PlexRequests.Core; using PlexRequests.Core.SettingModels; using PlexRequests.Services.Interfaces; using PlexRequests.Helpers; using PlexRequests.Services.Jobs; +using PlexRequests.Services.Models; using PlexRequests.Store.Models; using PlexRequests.Store.Repository; +using Ploeh.AutoFixture; + namespace PlexRequests.Services.Tests { [TestFixture] public class PlexAvailabilityCheckerTests { public IAvailabilityChecker Checker { get; set; } + private Fixture F { get; set; } = new Fixture(); private Mock> SettingsMock { get; set; } private Mock> AuthMock { get; set; } private Mock RequestMock { get; set; } @@ -82,27 +91,190 @@ namespace PlexRequests.Services.Tests PlexMock.Verify(x => x.GetUsers(It.IsAny()), Times.Never); } - //[Test] - //public void IsAvailableTest() - //{ - // var settingsMock = new Mock>(); - // var authMock = new Mock>(); - // var requestMock = new Mock(); - // var plexMock = new Mock(); - // var cacheMock = new Mock(); + [TestCaseSource(nameof(IsMovieAvailableTestData))] + public bool IsMovieAvailableTest(string title, string year) + { + var movies = new List + { + new PlexMovie {Title = title, ProviderId = null, ReleaseYear = year} + }; + var result = Checker.IsMovieAvailable(movies.ToArray(), "title", "2011"); - // var searchResult = new PlexSearch { Video = new List