test: Fixed tests

pull/4322/head
tidusjar 3 years ago
parent 5fee6d4686
commit c35ac16e19

@ -112,7 +112,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = DateTime.Now.AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -145,7 +145,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -220,7 +220,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -253,7 +253,7 @@ namespace Ombi.Core.Tests.Engine
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -286,7 +286,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -325,7 +325,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var lastWeek = new DateTime(2020, 10, 05).FirstDateInWeek().AddDays(-1); // Day before reset
var lastWeek = new DateTime(2020, 09, 05).FirstDateInWeek().AddDays(-1); // Day before reset
var log = new List<RequestLog>
{
new RequestLog
@ -428,7 +428,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var lastWeek = new DateTime(2020, 10, 05).AddMonths(-1).AddDays(-1);
var lastWeek = new DateTime(2020, 09, 05).AddMonths(-1).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -460,7 +460,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var firstDayOfMonth = new DateTime(today.Year, today.Month, 1);
var log = new List<RequestLog>
{
@ -494,7 +494,7 @@ namespace Ombi.Core.Tests.Engine
MovieRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var firstDayOfMonth = new DateTime(today.Year, today.Month, 1);
var log = new List<RequestLog>
{

@ -112,7 +112,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = DateTime.UtcNow.AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -145,7 +145,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -220,7 +220,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -253,7 +253,7 @@ namespace Ombi.Core.Tests.Engine
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -286,7 +286,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -325,7 +325,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var lastWeek = new DateTime(2020, 10, 05).FirstDateInWeek().AddDays(-1); // Day before reset
var lastWeek = new DateTime(2020, 09, 05).FirstDateInWeek().AddDays(-1); // Day before reset
var log = new List<RequestLog>
{
new RequestLog
@ -390,20 +390,20 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
{
UserId = "id1",
RequestType = RequestType.Album,
RequestDate = today,
RequestDate = today.AddMinutes(-2),
},
new RequestLog
{
UserId = "id1",
RequestType = RequestType.Album,
RequestDate = today,
RequestDate = today.AddMinutes(-1),
},
};
var repoMock = _mocker.GetMock<IRepository<RequestLog>>();
@ -428,7 +428,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var lastWeek = new DateTime(2020, 10, 05).AddMonths(-1).AddDays(-1);
var lastWeek = new DateTime(2020, 09, 05).AddMonths(-1).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -460,7 +460,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var firstDayOfMonth = new DateTime(today.Year, today.Month, 1);
var log = new List<RequestLog>
{
@ -494,7 +494,7 @@ namespace Ombi.Core.Tests.Engine
MusicRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var firstDayOfMonth = new DateTime(today.Year, today.Month, 1);
var log = new List<RequestLog>
{

@ -109,7 +109,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = DateTime.UtcNow.AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -142,7 +142,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimit = 2,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -225,7 +225,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var yesterday = new DateTime(2020, 10, 05).AddDays(-1);
var yesterday = new DateTime(2020, 09, 05).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -258,7 +258,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -292,7 +292,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -333,7 +333,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Day,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -407,7 +407,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -441,7 +441,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -482,7 +482,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Week,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -523,7 +523,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var lastWeek = new DateTime(2020, 10, 05).AddMonths(-1).AddDays(-1);
var lastWeek = new DateTime(2020, 09, 05).AddMonths(-1).AddDays(-1);
var log = new List<RequestLog>
{
new RequestLog
@ -556,7 +556,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -590,7 +590,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog
@ -631,7 +631,7 @@ namespace Ombi.Core.Tests.Engine
EpisodeRequestLimitType = RequestLimitType.Month,
Id = "id1"
};
var today = new DateTime(2020, 10, 05);
var today = DateTime.UtcNow;
var log = new List<RequestLog>
{
new RequestLog

@ -153,7 +153,7 @@ namespace Ombi.Core.Services
nextRequest = oldestRequestedAt.AddDays(1).Date;
break;
case RequestLimitType.Week:
var fdow = DateTime.UtcNow.FirstDateInWeek();
var fdow = DateTime.UtcNow.FirstDateInWeek().Date;
count = limit - await log.CountAsync(x => x.RequestDate >= fdow);
oldestRequestedAt = await log.Where(x => x.RequestDate >= fdow)
.OrderBy(x => x.RequestDate)
@ -262,7 +262,7 @@ namespace Ombi.Core.Services
nextRequest = oldestRequestedAt.AddDays(1).Date;
break;
case RequestLimitType.Week:
var fdow = now.FirstDateInWeek();
var fdow = now.FirstDateInWeek().Date;
filteredLog = log.Where(x => x.RequestDate >= DateTime.UtcNow.Date.AddDays(-7));
// Needed, due to a bug which would cause all episode counts to be 0
zeroEpisodeCount = await filteredLog.Where(x => x.EpisodeCount == 0).Select(x => x.EpisodeCount).CountAsync();

Loading…
Cancel
Save