|
|
@ -6,19 +6,20 @@ using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Jobs;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
public class ObjectDatabaseFixture : DbTest<BasicRepository<BasicType>, BasicType>
|
|
|
|
public class ObjectDatabaseFixture : DbTest<BasicRepository<JobDefinition>, JobDefinition>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private BasicType _sampleType;
|
|
|
|
private JobDefinition _sampleType;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void SetUp()
|
|
|
|
public void SetUp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_sampleType = Builder<BasicType>
|
|
|
|
_sampleType = Builder<JobDefinition>
|
|
|
|
.CreateNew()
|
|
|
|
.CreateNew()
|
|
|
|
.With(s => s.Id = 0)
|
|
|
|
.With(s => s.Id = 0)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
@ -29,7 +30,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
public void should_be_able_to_write_to_database()
|
|
|
|
public void should_be_able_to_write_to_database()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
Db.All<BasicType>().Should().HaveCount(1);
|
|
|
|
Db.All<JobDefinition>().Should().HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_be_able_to_store_empty_list()
|
|
|
|
public void should_be_able_to_store_empty_list()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var series = new List<BasicType>();
|
|
|
|
var series = new List<JobDefinition>();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.InsertMany(series);
|
|
|
|
Subject.InsertMany(series);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -68,7 +69,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
_sampleType.Id = 0;
|
|
|
|
_sampleType.Id = 0;
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
|
|
|
|
|
|
|
|
Db.All<BasicType>().Should().HaveCount(1);
|
|
|
|
Db.All<JobDefinition>().Should().HaveCount(1);
|
|
|
|
_sampleType.Id.Should().Be(1);
|
|
|
|
_sampleType.Id.Should().Be(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -80,7 +81,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_sampleType.Id = 0;
|
|
|
|
_sampleType.Id = 0;
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
var item = Db.All<BasicType>();
|
|
|
|
var item = Db.All<JobDefinition>();
|
|
|
|
|
|
|
|
|
|
|
|
item.Should().HaveCount(1);
|
|
|
|
item.Should().HaveCount(1);
|
|
|
|
item.First().Id.Should().NotBe(0);
|
|
|
|
item.First().Id.Should().NotBe(0);
|
|
|
@ -92,7 +93,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
public void should_be_able_to_find_object_by_id()
|
|
|
|
public void should_be_able_to_find_object_by_id()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
Subject.Insert(_sampleType);
|
|
|
|
var item = Db.All<BasicType>().Single(c => c.Id == _sampleType.Id);
|
|
|
|
var item = Db.All<JobDefinition>().Single(c => c.Id == _sampleType.Id);
|
|
|
|
|
|
|
|
|
|
|
|
item.Id.Should().NotBe(0);
|
|
|
|
item.Id.Should().NotBe(0);
|
|
|
|
item.Id.Should().Be(_sampleType.Id);
|
|
|
|
item.Id.Should().Be(_sampleType.Id);
|
|
|
@ -102,25 +103,25 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void update_field_should_only_update_that_filed()
|
|
|
|
public void update_field_should_only_update_that_filed()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var childModel = new BasicType
|
|
|
|
var childModel = new JobDefinition
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Address = "Address",
|
|
|
|
Type = "Address",
|
|
|
|
Name = "Name",
|
|
|
|
Name = "Name",
|
|
|
|
Tilte = "Title"
|
|
|
|
Interval = 12
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Insert(childModel);
|
|
|
|
Subject.Insert(childModel);
|
|
|
|
|
|
|
|
|
|
|
|
childModel.Address = "A";
|
|
|
|
childModel.Type = "A";
|
|
|
|
childModel.Name = "B";
|
|
|
|
childModel.Name = "B";
|
|
|
|
childModel.Tilte = "C";
|
|
|
|
childModel.Interval = 0;
|
|
|
|
|
|
|
|
|
|
|
|
Subject.UpdateFields(childModel, t => t.Name);
|
|
|
|
Subject.UpdateFields(childModel, t => t.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Db.All<BasicType>().Single().Address.Should().Be("Address");
|
|
|
|
Db.All<JobDefinition>().Single().Type.Should().Be("Address");
|
|
|
|
Db.All<BasicType>().Single().Name.Should().Be("B");
|
|
|
|
Db.All<JobDefinition>().Single().Name.Should().Be("B");
|
|
|
|
Db.All<BasicType>().Single().Tilte.Should().Be("Title");
|
|
|
|
Db.All<JobDefinition>().Single().Interval.Should().Be(12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|