|
|
@ -10,20 +10,25 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
public class ObjectDatabaseFixture : ObjectDbTest
|
|
|
|
public class ObjectDatabaseFixture : ObjectDbTest
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private Series testSeries;
|
|
|
|
|
|
|
|
private Episode testEpisode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void SetUp()
|
|
|
|
public void SetUp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithObjectDb();
|
|
|
|
WithObjectDb();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
testEpisode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_be_able_to_write_to_database()
|
|
|
|
public void should_be_able_to_write_to_database()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Db.Insert(testSeries);
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.Create(series);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.AsQueryable<Series>().Should().HaveCount(1);
|
|
|
|
Db.AsQueryable<Series>().Should().HaveCount(1);
|
|
|
|
|
|
|
|
|
|
|
@ -32,14 +37,11 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_store_dirty_data_in_cache()
|
|
|
|
public void should_not_store_dirty_data_in_cache()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
Db.Insert(testEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
//Save series without episode attached
|
|
|
|
|
|
|
|
Db.Create(episode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
|
|
|
|
|
|
|
|
|
|
|
episode.Series = Builder<Series>.CreateNew().Build();
|
|
|
|
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -49,10 +51,9 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_store_nested_objects()
|
|
|
|
public void should_store_nested_objects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
testEpisode.Series = testSeries;
|
|
|
|
episode.Series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.Create(episode);
|
|
|
|
Db.Insert(testEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
|
|
|
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
|
|
@ -61,18 +62,26 @@ namespace NzbDrone.Core.Test.Datastore
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_update_nested_objects()
|
|
|
|
public void should_update_nested_objects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
|
|
|
episode.Series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.Create(episode);
|
|
|
|
Db.Insert(testEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
episode.Series.Title = "UpdatedTitle";
|
|
|
|
testEpisode.Series.Title = "UpdatedTitle";
|
|
|
|
|
|
|
|
|
|
|
|
Db.Update(episode);
|
|
|
|
Db.Update(testEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
|
|
|
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle");
|
|
|
|
Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void new_objects_should_get_id()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Db.Insert(testSeries);
|
|
|
|
|
|
|
|
testSeries.Id.Should().NotBe(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|