From 1740852aa88ab81ce294e7bac26b5ab59fee46cb Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 17 Jul 2019 23:13:48 +0100 Subject: [PATCH] !wip on unit tests --- .../Engine/V2/MovieRequestEngineTests.cs | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs diff --git a/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs b/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs new file mode 100644 index 000000000..805440837 --- /dev/null +++ b/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Linq; +using System.Security.Principal; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Moq; +using NUnit.Framework; +using Ombi.Api.TheMovieDb; +using Ombi.Core.Engine; +using Ombi.Core.Models.Requests; +using Ombi.Core.Rule.Interfaces; +using Ombi.Core.Settings; +using Ombi.Helpers; +using Ombi.Settings.Settings.Models; +using Ombi.Store.Entities; +using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository; +using Ombi.Store.Repository.Requests; +using Ombi.Test.Common; + +namespace Ombi.Core.Tests.Engine.V2 +{ + [TestFixture] + public class MovieRequestEngineTests + { + private MovieRequestEngine _engine; + private Mock _movieRequestRepository; + [SetUp] + public void Setup() + { + var movieApi = new Mock(); + var requestService = new Mock(); + _movieRequestRepository = new Mock(); + requestService.Setup(x => x.MovieRequestService).Returns(_movieRequestRepository.Object); + var user = new Mock(); + var notificationHelper = new Mock(); + var rules = new Mock(); + var movieSender = new Mock(); + var logger = new Mock>(); + var userManager = MockHelper.MockUserManager(new List()); + var requestLogRepo = new Mock>(); + var cache = new Mock(); + var ombiSettings = new Mock>(); + var requestSubs = new Mock>(); + _engine = new MovieRequestEngine(movieApi.Object, requestService.Object, user.Object, notificationHelper.Object, rules.Object, movieSender.Object, + logger.Object, userManager.Object, requestLogRepo.Object, cache.Object, ombiSettings.Object, requestSubs.Object); + } + + [Test] + [Ignore("Needs to be tested")] + public async Task Get_UnavailableRequests() + { + _movieRequestRepository.Setup(x => x.GetWithUser()).Returns(new List + { + new MovieRequests + { + Available = true + }, + new MovieRequests + { + Available = false, + Approved = false + }, + new MovieRequests + { + Available = false, + Approved = true, + Title = "Come get me" + } + }.AsQueryable()); + var result = await _engine.GetUnavailableRequests(100, 0, "RequestedDate", "asc"); + + Assert.That(result.Total, Is.EqualTo(1)); + Assert.That(result.Collection.FirstOrDefault().Title, Is.EqualTo("Come get me")); + } + } +} \ No newline at end of file