2013-02-23 21:29:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.History;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-09-18 05:28:05 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-02-23 21:29:22 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.HistoryTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-03-27 00:51:37 +00:00
|
|
|
|
public class HistoryRepositoryFixture : DbTest<HistoryRepository, History.History>
|
2013-02-23 21:29:22 +00:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void Trim_Items()
|
|
|
|
|
{
|
|
|
|
|
var historyItem = Builder<History.History>.CreateListOfSize(30)
|
|
|
|
|
.All()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.With(c=>c.Id = 0)
|
2013-02-23 21:29:22 +00:00
|
|
|
|
.TheFirst(10).With(c => c.Date = DateTime.Now)
|
|
|
|
|
.TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.InsertMany(historyItem);
|
|
|
|
|
|
|
|
|
|
AllStoredModels.Should().HaveCount(30);
|
|
|
|
|
Subject.Trim();
|
|
|
|
|
|
|
|
|
|
AllStoredModels.Should().HaveCount(10);
|
|
|
|
|
AllStoredModels.Should().OnlyContain(s => s.Date > DateTime.Now.AddDays(-30));
|
|
|
|
|
}
|
2013-06-09 06:20:38 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_read_write_dictionary()
|
|
|
|
|
{
|
|
|
|
|
var history = Builder<History.History>.CreateNew().BuildNew();
|
|
|
|
|
|
|
|
|
|
history.Data.Add("key1","value1");
|
|
|
|
|
history.Data.Add("key2","value2");
|
|
|
|
|
|
|
|
|
|
Subject.Insert(history);
|
|
|
|
|
|
|
|
|
|
StoredModel.Data.Should().HaveCount(2);
|
|
|
|
|
}
|
2013-02-23 21:29:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|