1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Broke some Eloquera tests to prove a point

This commit is contained in:
Mark McDowall 2013-02-06 00:40:57 -08:00 committed by kay.one
parent 04dda9384f
commit 8c99cca207
3 changed files with 37 additions and 15 deletions

View File

@ -14,14 +14,19 @@ public class ObjectDatabaseFixture : ObjectDbTest
private Series testSeries; private Series testSeries;
private Episode testEpisode; private Episode testEpisode;
[SetUp] [SetUp]
public void SetUp() public void SetUp()
{ {
WithObjectDb(); WithObjectDb();
testSeries = Builder<Series>.CreateNew().Build(); testSeries = Builder<Series>
testEpisode = Builder<Episode>.CreateNew().Build(); .CreateNew()
.With(s => s.Id = 0)
.Build();
testEpisode = Builder<Episode>
.CreateNew()
.Build();
} }
@ -47,8 +52,6 @@ public void should_not_store_dirty_data_in_cache()
Db.AsQueryable<Episode>().Single().Series.Should().BeNull(); Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
} }
[Test] [Test]
public void should_store_nested_objects() public void should_store_nested_objects()
{ {
@ -76,7 +79,6 @@ public void should_update_nested_objects()
Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle"); Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle");
} }
[Test] [Test]
public void new_objects_should_get_id() public void new_objects_should_get_id()
{ {
@ -85,7 +87,28 @@ public void new_objects_should_get_id()
} }
[Test] [Test]
public void should_be_able_to_read_unknow_type() public void should_have_id_when_returned_from_database()
{
Db.Insert(testSeries);
var item = Db.AsQueryable<Series>();
item.Should().HaveCount(1);
item.First().Id.Should().NotBe(0);
item.First().Id.Should().Be(testSeries.Id);
}
[Test]
public void should_be_able_to_find_object_by_id()
{
Db.Insert(testSeries);
var item = Db.AsQueryable<Series>().Single(c => c.Id == testSeries.Id);
item.Id.Should().NotBe(0);
item.Id.Should().Be(testSeries.Id);
}
[Test]
public void should_be_able_to_read_unknown_type()
{ {
Db.AsQueryable<UnknownType>().ToList().Should().BeEmpty(); Db.AsQueryable<UnknownType>().ToList().Should().BeEmpty();
} }

View File

@ -22,25 +22,24 @@ public BasicRepository(EloqueraDb eloqueraDb)
protected EloqueraDb EloqueraDb { get; private set; } protected EloqueraDb EloqueraDb { get; private set; }
public List<TModel> All() public List<TModel> All()
{ {
return EloqueraDb.AsQueryable<TModel>().ToList(); return EloqueraDb.AsQueryable<TModel>().ToList();
} }
public TModel Get(int rootFolderId) public TModel Get(int id)
{ {
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == rootFolderId); return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == id);
} }
public TModel Add(TModel rootFolder) public TModel Add(TModel model)
{ {
return EloqueraDb.Insert(rootFolder); return EloqueraDb.Insert(model);
} }
public void Delete(int rootFolderId) public void Delete(int id)
{ {
var itemToDelete = Get(rootFolderId); var itemToDelete = Get(id);
EloqueraDb.Delete(itemToDelete); EloqueraDb.Delete(itemToDelete);
} }
} }

View File

@ -12,7 +12,7 @@ public class Series
{ {
[ID] [ID]
public int Id; public long Id;
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }