mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
cleaned up some tests.
This commit is contained in:
parent
1ccbb3c9d8
commit
35cb7e55c7
9 changed files with 116 additions and 218 deletions
84
NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs
Normal file
84
NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
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 BaiscType : ModelBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Tilte { get; set; }
|
||||
public string Address { get; set; }
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class BasicRepositoryFixture : ObjectDbTest<BasicRepository<BaiscType>,BaiscType>
|
||||
{
|
||||
private BaiscType _baiscType;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_baiscType = Builder<BaiscType>
|
||||
.CreateNew()
|
||||
.With(c => c.Id = 0)
|
||||
.Build();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_add()
|
||||
{
|
||||
Subject.Insert(_baiscType);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_delete_model()
|
||||
{
|
||||
Subject.Insert(_baiscType);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
|
||||
Subject.Delete(_baiscType.Id);
|
||||
Subject.All().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_find_by_id()
|
||||
{
|
||||
Subject.Insert(_baiscType);
|
||||
Subject.Get(_baiscType.Id)
|
||||
.ShouldHave()
|
||||
.AllProperties()
|
||||
.EqualTo(_baiscType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void getting_model_with_invalid_id_should_throw()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Subject.Get(12));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void get_all_with_empty_db_should_return_empty_list()
|
||||
{
|
||||
Subject.All().Should().BeEmpty();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_call_ToList_on_empty_quariable()
|
||||
{
|
||||
Subject.All().ToList().Should().BeEmpty();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue