Revert "Swap to dapper and system.text.json for database backend"

This reverts commit d2065bfa1b.
This commit is contained in:
Qstick
2019-12-17 21:17:47 -05:00
parent d778085ba5
commit e937d74b11
155 changed files with 2335 additions and 2328 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@@ -16,7 +15,7 @@ namespace NzbDrone.Core.Test.Datastore
BasicRepositoryFixture : DbTest<BasicRepository<ScheduledTask>, ScheduledTask>
{
private ScheduledTask _basicType;
private List<ScheduledTask> _basicList;
[SetUp]
public void Setup()
@@ -26,28 +25,15 @@ namespace NzbDrone.Core.Test.Datastore
.With(c => c.Id = 0)
.With(c => c.LastExecution = DateTime.UtcNow)
.Build();
_basicList = Builder<ScheduledTask>
.CreateListOfSize(5)
.All()
.With(x => x.Id = 0)
.BuildList();
}
[Test]
public void should_be_able_to_insert()
public void should_be_able_to_add()
{
Subject.Insert(_basicType);
Subject.All().Should().HaveCount(1);
}
[Test]
public void should_be_able_to_insert_many()
{
Subject.InsertMany(_basicList);
Subject.All().Should().HaveCount(5);
}
[Test]
public void purge_should_delete_all()
{
@@ -61,6 +47,7 @@ namespace NzbDrone.Core.Test.Datastore
}
[Test]
public void should_be_able_to_delete_model()
{
@@ -71,16 +58,6 @@ namespace NzbDrone.Core.Test.Datastore
Subject.All().Should().BeEmpty();
}
[Test]
public void should_be_able_to_delete_many()
{
Subject.InsertMany(_basicList);
Subject.All().Should().HaveCount(5);
Subject.DeleteMany(_basicList.Take(2).ToList());
Subject.All().Should().HaveCount(3);
}
[Test]
public void should_be_able_to_find_by_id()
{
@@ -90,64 +67,6 @@ namespace NzbDrone.Core.Test.Datastore
storeObject.Should().BeEquivalentTo(_basicType, o=>o.IncludingAllRuntimeProperties());
}
[Test]
public void should_be_able_to_find_by_multiple_id()
{
Subject.InsertMany(_basicList);
var storeObject = Subject.Get(_basicList.Take(2).Select(x => x.Id));
storeObject.Should().HaveCount(2);
}
[Test]
public void should_be_able_to_update()
{
Subject.Insert(_basicType);
_basicType.Interval = 999;
Subject.Update(_basicType);
Subject.All().First().Interval.Should().Be(999);
}
[Test]
public void should_be_able_to_update_many()
{
Subject.InsertMany(_basicList);
_basicList.ForEach(x => x.Interval = 999);
Subject.UpdateMany(_basicList);
Subject.All().All(x => x.Interval == 999);
}
[Test]
public void should_be_able_to_update_single_field()
{
Subject.Insert(_basicType);
_basicType.Interval = 999;
_basicType.LastExecution = DateTime.UtcNow;
Subject.SetFields(_basicType, x => x.Interval);
var dbValue = Subject.Single();
dbValue.Interval.Should().Be(999);
dbValue.LastExecution.Should().NotBe(_basicType.LastExecution);
}
[Test]
public void should_be_able_to_update_many_single_field()
{
Subject.InsertMany(_basicList);
_basicList.ForEach(x => x.Interval = 999);
_basicList.ForEach(x => x.LastExecution = DateTime.UtcNow);
Subject.SetFields(_basicList, x => x.Interval);
var dbValue = Subject.All().First();
dbValue.Interval.Should().Be(999);
dbValue.LastExecution.Should().NotBe(_basicType.LastExecution);
}
[Test]
public void should_be_able_to_get_single()
{
@@ -167,6 +86,7 @@ namespace NzbDrone.Core.Test.Datastore
Assert.Throws<ModelNotFoundException>(() => Subject.Get(12));
}
[Test]
public void get_all_with_empty_db_should_return_empty_list()
{
@@ -178,6 +98,7 @@ namespace NzbDrone.Core.Test.Datastore
public void should_be_able_to_call_ToList_on_empty_quariable()
{
Subject.All().ToList().Should().BeEmpty();
}
}
}
}