pull/1510/head
Jamie.Rees 7 years ago
parent 36d93d5a9d
commit 599cb013d5

@ -1,4 +1,4 @@
#tool "xunit.runner.console"
#tool "nuget:?package=NUnit.Runners
#tool "nuget:?package=GitVersion.CommandLine"
#addin "Cake.Gulp"
#addin "Cake.Npm"
@ -174,49 +174,50 @@ Task("Publish-OSX")
Task("Publish-Ubuntu")
.Does(() =>
{
publishSettings.Runtime = "ubuntu-x64";
publishSettings.Runtime = "ubuntu-x64";
publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/ubuntu-x64/published");
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
CopyFile(buildDir + "/netcoreapp2.0/ubuntu-x64/Swagger.xml", buildDir + "/netcoreapp2.0/ubuntu-x64/published/Swagger.xml");
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
});
Task("Publish-Debian")
.Does(() =>
{
publishSettings.Runtime = "debian.8-x64";
publishSettings.Runtime = "debian.8-x64";
publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/debian.8-x64/published");
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
CopyFile(buildDir + "/netcoreapp2.0/debian.8-x64/Swagger.xml", buildDir + "/netcoreapp2.0/debian.8-x64/published/Swagger.xml");
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
});
Task("Publish-Centos")
.Does(() =>
{
publishSettings.Runtime = "centos.7-x64";
publishSettings.Runtime = "centos.7-x64";
publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/centos.7-x64/published");
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
CopyFile(buildDir + "/netcoreapp2.0/centos.7-x64/Swagger.xml", buildDir + "/netcoreapp2.0/centos.7-x64/published/Swagger.xml");
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
});
Task("Publish-Linux")
.Does(() =>
{
publishSettings.Runtime = "linux-x64";
publishSettings.Runtime = "linux-x64";
publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/linux-x64/published");
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings);
CopyFile(buildDir + "/netcoreapp2.0/linux-x64/Swagger.xml", buildDir + "/netcoreapp2.0/linux-x64/published/Swagger.xml");
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings);
});
Task("Run-Unit-Tests")
.IsDependentOn("Publish")
.Does(() =>
{
NUnit("./src/**/bin/Release/*.Tests.dll");
});
//////////////////////////////////////////////////////////////////////

@ -2,14 +2,16 @@
//using System.Linq;
//using System.Threading.Tasks;
//using Moq;
//using NUnit.Framework;
//using Ombi.Core.Engine;
//using Ombi.Core.Models.Requests;
//using Ombi.Store.Entities.Requests;
//using Ombi.Store.Repository;
//using Xunit;
//using Assert = Xunit.Assert;
//namespace Ombi.Core.Tests.Engine
//{
// [TestFixture]
// public class MovieRequestEngineTests
// {
// public MovieRequestEngineTests()
@ -22,7 +24,7 @@
// private MovieRequestEngine Engine { get; }
// private Mock<IMovieRequestRepository> RequestService { get; }
// [Fact]
// [Test]
// public async Task GetNewRequests_Should_ReturnEmpty_WhenThereAreNoNewRequests()
// {
// var requests = new List<MovieRequests>
@ -39,95 +41,95 @@
// Assert.False(result.Any());
// }
// //[Fact]
// //public async Task GetNewRequests_Should_ReturnOnlyNewRequests_WhenThereAreMultipleRequests()
// //{
// // var requests = new List<MovieRequestModel>
// // {
// // new MovieRequestModel { Available = true },
// // new MovieRequestModel { Approved = true },
// // new MovieRequestModel(),
// // };
// // RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
// // var result = await Engine.GetNewRequests();
// // Assert.Equal(result.Count(), 1);
// // Assert.All(result, x =>
// // {
// // Assert.Equal(x.Available, false);
// // Assert.Equal(x.Approved, false);
// // });
// //}
// //[Fact]
// //public async Task GetApprovedRequests_Should_ReturnEmpty_WhenThereAreNoApprovedRequests()
// //{
// // var requests = new List<MovieRequestModel>
// // {
// // new MovieRequestModel { Available = true },
// // };
// // RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
// // var result = await Engine.GetApprovedRequests();
// // Assert.False(result.Any());
// //}
// //[Fact]
// //public async Task GetApprovedRequests_Should_ReturnOnlyApprovedRequests_WhenThereAreMultipleRequests()
// //{
// // var requests = new List<MovieRequestModel>
// // {
// // new MovieRequestModel { Available = true },
// // new MovieRequestModel { Approved = true },
// // new MovieRequestModel(),
// // };
// // RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
// // var result = await Engine.GetApprovedRequests();
// // Assert.Equal(result.Count(), 1);
// // Assert.All(result, x =>
// // {
// // Assert.Equal(x.Available, false);
// // Assert.Equal(x.Approved, true);
// // });
// //}
// //[Fact]
// //public async Task GetAvailableRequests_Should_ReturnEmpty_WhenThereAreNoAvailableRequests()
// //{
// // var requests = new List<MovieRequestModel>
// // {
// // new MovieRequestModel { Approved = true },
// // };
// // RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
// // var result = await Engine.GetAvailableRequests();
// // Assert.False(result.Any());
// //}
// //[Fact]
// //public async Task GetAvailableRequests_Should_ReturnOnlyAvailableRequests_WhenThereAreMultipleRequests()
// //{
// // var requests = new List<MovieRequestModel>
// // {
// // new MovieRequestModel { Available = true },
// // new MovieRequestModel { Approved = true },
// // new MovieRequestModel(),
// // };
// // RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
// // var result = await Engine.GetAvailableRequests();
// // Assert.Equal(result.Count(), 1);
// // Assert.All(result, x =>
// // {
// // Assert.Equal(x.Available, true);
// // Assert.Equal(x.Approved, false);
// // });
// //}
// [Test]
// public async Task GetNewRequests_Should_ReturnOnlyNewRequests_WhenThereAreMultipleRequests()
// {
// var requests = new List<MovieRequests>
// {
// new MovieRequests { Available = true },
// new MovieRequests { Approved = true },
// new MovieRequests(),
// };
// RequestService.Setup(x => x.Get()).Returns(requests.AsQueryable);
// var result = await Engine.GetNewRequests();
// Assert.Single(result);
// Assert.All(result, x =>
// {
// Assert.False(x.Available);
// Assert.False(x.Approved);
// });
// }
// [Test]
// public async Task GetApprovedRequests_Should_ReturnEmpty_WhenThereAreNoApprovedRequests()
// {
// var requests = new List<MovieRequests>
// {
// new MovieRequests { Available = true },
// };
// RequestService.Setup(x => x.Get()).Returns(requests.AsQueryable);
// var result = await Engine.GetApprovedRequests();
// Assert.False(result.Any());
// }
// [Test]
// public async Task GetApprovedRequests_Should_ReturnOnlyApprovedRequests_WhenThereAreMultipleRequests()
// {
// var requests = new List<MovieRequests>
// {
// new MovieRequests { Available = true },
// new MovieRequests { Approved = true },
// new MovieRequests(),
// };
// RequestService.Setup(x => x.Get()).Returns(requests.AsQueryable);
// var result = await Engine.GetApprovedRequests();
// Assert.Single(result);
// Assert.All(result, x =>
// {
// Assert.False(x.Available);
// Assert.True(x.Approved);
// });
// }
// [Test]
// public async Task GetAvailableRequests_Should_ReturnEmpty_WhenThereAreNoAvailableRequests()
// {
// var requests = new List<MovieRequests>
// {
// new MovieRequests { Approved = true },
// };
// RequestService.Setup(x => x.Get()).Returns(requests.AsQueryable);
// var result = await Engine.GetAvailableRequests();
// Assert.False(result.Any());
// }
// [Test]
// public async Task GetAvailableRequests_Should_ReturnOnlyAvailableRequests_WhenThereAreMultipleRequests()
// {
// var requests = new List<MovieRequests>
// {
// new MovieRequests { Available = true },
// new MovieRequests { Approved = true },
// new MovieRequests(),
// };
// RequestService.Setup(x => x.Get()).Returns(requests.AsQueryable);
// var result = await Engine.GetAvailableRequests();
// Assert.Single(result);
// Assert.All(result, x =>
// {
// Assert.True(x.Available);
// Assert.False(x.Approved);
// });
// }
// }
//}

@ -5,9 +5,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.7.10" />
<PackageReference Include="xunit" Version="2.3.0-beta4-build3742" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta4-build3742" />
<PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
<PackageReference Include="Nunit" Version="3.7.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" />
</ItemGroup>

@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -112,7 +113,6 @@ namespace Ombi.DependencyInjection
services.AddSingleton<IEmailProvider, GenericEmailProvider>();
services.AddTransient<INotificationHelper, NotificationHelper>();
services.AddTransient<IDiscordNotification, DiscordNotification>();
services.AddTransient<IEmailNotification, EmailNotification>();
services.AddTransient<IPushbulletNotification, PushbulletNotification>();
@ -120,6 +120,8 @@ namespace Ombi.DependencyInjection
services.AddTransient<ISlackNotification, SlackNotification>();
services.AddTransient<IMattermostNotification, MattermostNotification>();
services.AddTransient<IPushoverNotification, PushoverNotification>();
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>();
}
public static void RegisterJobs(this IServiceCollection services)

@ -5,10 +5,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Moq" Version="4.7.10" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170914-09" />
<PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
</ItemGroup>
<ItemGroup>

@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Hangfire;
using Moq;
using NUnit.Framework;
using Ombi.Core.Notifications;
@ -23,7 +24,7 @@ namespace Ombi.Schedule.Tests
_movie = new Mock<IMovieRequestRepository>();
_movie = new Mock<IMovieRequestRepository>();
_notify = new Mock<INotificationService>();
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object);
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object);
}
private readonly Mock<IPlexContentRepository> _repo;
@ -59,8 +60,7 @@ namespace Ombi.Schedule.Tests
_movie.Setup(x => x.Get()).Returns(new List<MovieRequests> { request }.AsQueryable());
await Checker.Start();
_movie.Verify(x => x.Save(), Times.Once);
Assert.False(request.Available);
}

@ -15,18 +15,20 @@ namespace Ombi.Schedule.Jobs.Plex
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
{
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
INotificationService notification)
INotificationService notification, IBackgroundJobClient background)
{
_tvRepo = tvRequest;
_repo = repo;
_movieRepo = movies;
_notificationService = notification;
_backgroundJobClient = background;
}
private readonly ITvRequestRepository _tvRepo;
private readonly IMovieRequestRepository _movieRepo;
private readonly IPlexContentRepository _repo;
private readonly INotificationService _notificationService;
private readonly IBackgroundJobClient _backgroundJobClient;
public async Task Start()
{
@ -64,7 +66,7 @@ namespace Ombi.Schedule.Jobs.Plex
{
// We have fulfulled this request!
child.Available = true;
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
_backgroundJobClient.Enqueue(() => _notificationService.Publish(new NotificationOptions
{
DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable,
@ -94,7 +96,7 @@ namespace Ombi.Schedule.Jobs.Plex
movie.Available = true;
if (movie.Available)
{
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
_backgroundJobClient.Enqueue(() => _notificationService.Publish(new NotificationOptions
{
DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable,

@ -22,7 +22,6 @@ namespace Ombi.Store.Context
}
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<PlexContent> PlexContent { get; set; }

@ -10,8 +10,8 @@ if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => {
// Before restarting the app, we create a new root element and dispose the old one
const oldRootElem = document.querySelector('app');
const newRootElem = document.createElement('app');
const oldRootElem = document.querySelector('ombi');
const newRootElem = document.createElement('ombi');
if (oldRootElem && oldRootElem.parentNode) {
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
}

@ -196,9 +196,6 @@ namespace Ombi
{
var ctx = serviceProvider.GetService<IOmbiContext>();
loggerFactory.AddSerilog();
if (env.IsDevelopment())

Loading…
Cancel
Save