|
|
|
@ -1,13 +1,11 @@
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Moq;
|
|
|
|
|
using Ombi.Core.Models.Requests;
|
|
|
|
|
using Ombi.Core.Models.Requests.Movie;
|
|
|
|
|
using Ombi.Core.Models.Search;
|
|
|
|
|
using Ombi.Core.Requests.Models;
|
|
|
|
|
using Ombi.Core.Rule.Rules.Search;
|
|
|
|
|
using Ombi.Store.Context;
|
|
|
|
|
using Ombi.Store.Entities;
|
|
|
|
|
using Ombi.Store.Repository;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Ombi.Core.Tests.Rule.Search
|
|
|
|
@ -25,20 +23,20 @@ namespace Ombi.Core.Tests.Rule.Search
|
|
|
|
|
private Mock<IRequestService<MovieRequestModel>> MovieMock { get; }
|
|
|
|
|
private Mock<IRequestService<TvRequestModel>> TvMock { get; }
|
|
|
|
|
|
|
|
|
|
// TODO continue tests
|
|
|
|
|
// https://stackoverflow.com/questions/27483709/testing-ef-async-methods-with-sync-methods-with-moq
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ShouldBe_Requested_WhenExisitngMovie()
|
|
|
|
|
{
|
|
|
|
|
var list = DbHelper.GetQueryableMockDbSet(new MovieRequestModel
|
|
|
|
|
var list = new List<MovieRequestModel>{new MovieRequestModel
|
|
|
|
|
{
|
|
|
|
|
ProviderId = 123,
|
|
|
|
|
Approved = true
|
|
|
|
|
});
|
|
|
|
|
MovieMock.Setup(x => x.GetAllQueryable()).Returns(list);
|
|
|
|
|
}};
|
|
|
|
|
MovieMock.Setup(x => x.GetAllAsync()).ReturnsAsync(list);
|
|
|
|
|
var search = new SearchMovieViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 123,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var result = await Rule.Execute(search);
|
|
|
|
|
|
|
|
|
@ -46,6 +44,66 @@ namespace Ombi.Core.Tests.Rule.Search
|
|
|
|
|
Assert.Equal(search.Approved, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ShouldBe_NotRequested_WhenNewMovie()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<MovieRequestModel>{new MovieRequestModel
|
|
|
|
|
{
|
|
|
|
|
ProviderId = 123,
|
|
|
|
|
Approved = true
|
|
|
|
|
}};
|
|
|
|
|
MovieMock.Setup(x => x.GetAllAsync()).ReturnsAsync(list);
|
|
|
|
|
var search = new SearchMovieViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 999,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var result = await Rule.Execute(search);
|
|
|
|
|
|
|
|
|
|
Assert.True(result.Success);
|
|
|
|
|
Assert.Equal(search.Approved, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ShouldBe_Requested_WhenExisitngTv()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<TvRequestModel>{new TvRequestModel
|
|
|
|
|
{
|
|
|
|
|
ProviderId = 123,
|
|
|
|
|
Approved = true
|
|
|
|
|
}};
|
|
|
|
|
TvMock.Setup(x => x.GetAllAsync()).ReturnsAsync(list);
|
|
|
|
|
var search = new SearchTvShowViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 123,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var result = await Rule.Execute(search);
|
|
|
|
|
|
|
|
|
|
Assert.True(result.Success);
|
|
|
|
|
Assert.Equal(search.Approved, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ShouldBe_NotRequested_WhenNewTv()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<TvRequestModel>{new TvRequestModel
|
|
|
|
|
{
|
|
|
|
|
ProviderId = 123,
|
|
|
|
|
Approved = true
|
|
|
|
|
}};
|
|
|
|
|
TvMock.Setup(x => x.GetAllAsync()).ReturnsAsync(list);
|
|
|
|
|
var search = new SearchTvShowViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = 999,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var result = await Rule.Execute(search);
|
|
|
|
|
|
|
|
|
|
Assert.True(result.Success);
|
|
|
|
|
Assert.Equal(search.Approved, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|