diff --git a/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs new file mode 100644 index 000000000..914e439e9 --- /dev/null +++ b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs @@ -0,0 +1,78 @@ +using System; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore +{ + + public class SampleType : BaseRepositoryModel + { + public string Name { get; set; } + public string Tilte { get; set; } + public string Address { get; set; } + } + + [TestFixture] + public class SimpleRepositoryFixture : ObjectDbTest> + { + private SampleType sampleType; + + + [SetUp] + public void Setup() + { + WithObjectDb(); + sampleType = Builder + .CreateNew() + .With(c => c.OID = 0) + .Build(); + + } + + [Test] + public void should_be_able_to_add() + { + Subject.Add(sampleType); + Subject.All().Should().HaveCount(1); + } + + + + [Test] + public void should_be_able_to_delete_model() + { + Subject.Add(sampleType); + Subject.All().Should().HaveCount(1); + + Subject.Delete(sampleType.OID); + Subject.All().Should().BeEmpty(); + } + + [Test] + public void should_be_able_to_find_by_id() + { + Subject.Add(sampleType); + Subject.Get(sampleType.OID) + .ShouldHave() + .AllProperties() + .EqualTo(sampleType); + } + + [Test] + public void getting_model_with_invalid_id_should_throw() + { + Assert.Throws(() => Subject.Get(12)); + } + + + [Test] + public void get_all_with_empty_db_should_return_empty_list() + { + Subject.All().Should().BeEmpty(); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 2ea240707..a56c11b31 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -151,6 +151,7 @@ + diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs index 8fdaef477..182e3b010 100644 --- a/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -6,9 +6,9 @@ namespace NzbDrone.Core.Datastore public interface IBasicRepository { List All(); - TModel Get(int rootFolderId); - TModel Add(TModel rootFolder); - void Delete(int rootFolderId); + TModel Get(int id); + TModel Add(TModel model); + void Delete(int id); } public class BasicRepository : IBasicRepository where TModel : BaseRepositoryModel, new() diff --git a/NzbDrone.sln.DotSettings b/NzbDrone.sln.DotSettings index 11cf96ccf..52ac224d3 100644 --- a/NzbDrone.sln.DotSettings +++ b/NzbDrone.sln.DotSettings @@ -10,6 +10,38 @@ 2 Backbone model 5 + True + True + Nunit Test + True + spacestounderstrokes(testname) + 0 + True + True + 4.0 + InCSharpQuery + test + True + [Test] +public void $testname$() +{ + + +} + True + True + Nunit Setup + True + True + 2.0 + InCSharpFile + Setup + True + [SetUp] + public void Setup() + { + + } True True js @@ -136,6 +168,40 @@ $ModelName$Collection = Backbone.Collection.extend({ initialize: function () { }, + True + True + cs + $ServiceName$Fixture + True + TestFixture + True + completeType() + 0 + True + list("CoreTest, ObjectDbTest") + 1 + True + True + InCSharpProjectFile + True + using System; +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Repository; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore +{ + [TestFixture] + public class $ServiceName$Fixture: $TestBase$<$ServiceName$> + { + + } +}