//#region Copyright //// /************************************************************************ //// Copyright (c) 2016 Jamie Rees //// File: SearchModuleTests.cs //// Created By: Jamie Rees //// //// Permission is hereby granted, free of charge, to any person obtaining //// a copy of this software and associated documentation files (the //// "Software"), to deal in the Software without restriction, including //// without limitation the rights to use, copy, modify, merge, publish, //// distribute, sublicense, and/or sell copies of the Software, and to //// permit persons to whom the Software is furnished to do so, subject to //// the following conditions: //// //// The above copyright notice and this permission notice shall be //// included in all copies or substantial portions of the Software. //// //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, //// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF //// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND //// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE //// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION //// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION //// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //// ************************************************************************/ //#endregion //using System; //using System.Collections.Generic; //using System.Linq; //using Moq; //using NUnit.Framework; //using PlexRequests.Api.Interfaces; //using PlexRequests.Api.Models.Plex; //using PlexRequests.Core; //using PlexRequests.Core.Queue; //using PlexRequests.Core.SettingModels; //using PlexRequests.Helpers; //using PlexRequests.Helpers.Analytics; //using PlexRequests.Services.Interfaces; //using PlexRequests.Services.Jobs; //using PlexRequests.Store; //using PlexRequests.Store.Models; //using PlexRequests.Store.Repository; //using PlexRequests.UI.Modules; //using Ploeh.AutoFixture; //namespace PlexRequests.UI.Tests //{ // [TestFixture] // public class SearchModuleTests // { // private Mock> _headphonesSettings; // private Mock _notificationService; // private Mock> _sickRageSettingsMock; // private Mock _cpApi; // private Mock> _sonarrSettingsMock; // private Mock _sonarrApiMock; // private Mock> _plexSettingsMock; // private Mock> _cpMock; // private Mock> _plexRequestMock; // private Mock> _authMock; // private Mock _analytics; // private Mock _availabilityMock; // private Mock _rServiceMock; // private Mock _srApi; // private Mock _music; // private Mock _hpAPi; // private Mock _cpCache; // private Mock _sonarrCache; // private Mock _srCache; // private Mock _plexApi; // private Mock> _userRepo; // private Mock> _emailSettings; // private Mock _issueService; // private Mock _cache; // private Mock _faultQueue; // private Mock> RequestLimitRepo { get; set; } // private SearchModule Search { get; set; } // private readonly Fixture F = new Fixture(); // [Test] // public void CheckNoRequestLimitTest() // { // var settings = new PlexRequestSettings { AlbumWeeklyRequestLimit = 0, MovieWeeklyRequestLimit = 2, TvWeeklyRequestLimit = 0 }; // var result = Search.CheckRequestLimit(settings, RequestType.Movie).Result; // Assert.That(result, Is.True); // RequestLimitRepo.Verify(x => x.GetAllAsync(), Times.Once); // } // [TestCaseSource(nameof(MovieLimitData))] // public bool CheckMovieLimitTest(int requestCount) // { // var users = F.CreateMany().ToList(); // users.Add(new RequestLimit { Username = "", RequestCount = requestCount, RequestType = RequestType.Movie}); // RequestLimitRepo.Setup(x => x.GetAllAsync()).ReturnsAsync(users); // var settings = new PlexRequestSettings { AlbumWeeklyRequestLimit = 0, MovieWeeklyRequestLimit = 5, TvWeeklyRequestLimit = 0 }; // var result = Search.CheckRequestLimit(settings, RequestType.Movie).Result; // RequestLimitRepo.Verify(x => x.GetAllAsync(), Times.Once); // return result; // } // private static IEnumerable MovieLimitData // { // get // { // yield return new TestCaseData(1).Returns(true).SetName("1 Request of 5"); // yield return new TestCaseData(2).Returns(true).SetName("2 Request of 5"); // yield return new TestCaseData(3).Returns(true).SetName("3 Request of 5"); // yield return new TestCaseData(4).Returns(true).SetName("4 Request of 5"); // yield return new TestCaseData(5).Returns(false).SetName("5 Request of 5"); // yield return new TestCaseData(6).Returns(false).SetName("6 Request of 5"); // yield return new TestCaseData(0).Returns(true).SetName("0 Request of 5"); // } // } // [SetUp] // public void Setup() // { // _authMock = new Mock>(); // _plexRequestMock = new Mock>(); // _plexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings()); // _cpMock = new Mock>(); // _plexSettingsMock = new Mock>(); // _sonarrApiMock = new Mock(); // _sonarrSettingsMock = new Mock>(); // _cpApi = new Mock(); // _sickRageSettingsMock = new Mock>(); // _notificationService = new Mock(); // _headphonesSettings = new Mock>(); // _cache = new Mock(); // _analytics = new Mock(); // _availabilityMock = new Mock(); // _rServiceMock = new Mock(); // _srApi = new Mock(); // _music = new Mock(); // _hpAPi = new Mock(); // _cpCache = new Mock(); // _sonarrCache = new Mock(); // _srCache = new Mock(); // _plexApi = new Mock(); // _userRepo = new Mock>(); // RequestLimitRepo = new Mock>(); // _emailSettings = new Mock>(); // _issueService = new Mock(); // _faultQueue = new Mock(); // CreateModule(); // } // private void CreateModule() // { // Search = new SearchModule(_cache.Object, _cpMock.Object, _plexRequestMock.Object, _availabilityMock.Object, // _rServiceMock.Object, _sonarrApiMock.Object, _sonarrSettingsMock.Object, // _sickRageSettingsMock.Object, _cpApi.Object, _srApi.Object, _notificationService.Object, // _music.Object, _hpAPi.Object, _headphonesSettings.Object, _cpCache.Object, _sonarrCache.Object, // _srCache.Object, _plexApi.Object, _plexSettingsMock.Object, _authMock.Object, // _userRepo.Object, _emailSettings.Object, _issueService.Object, _analytics.Object, RequestLimitRepo.Object, _faultQueue.Object); // } // } //}