1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-31 07:52:37 +01:00
Sonarr/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs

77 lines
1.8 KiB
C#
Raw Normal View History

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 : ModelBase
{
public string Name { get; set; }
public string Tilte { get; set; }
public string Address { get; set; }
}
[TestFixture]
2013-02-23 20:38:25 +01:00
public class SimpleRepositoryFixture : ObjectDbTest<BasicRepository<SampleType>,SampleType>
{
private SampleType sampleType;
[SetUp]
public void Setup()
{
sampleType = Builder<SampleType>
.CreateNew()
.With(c => c.Id = 0)
.Build();
}
[Test]
public void should_be_able_to_add()
{
2013-02-19 07:56:02 +01:00
Subject.Insert(sampleType);
Subject.All().Should().HaveCount(1);
}
[Test]
public void should_be_able_to_delete_model()
{
2013-02-19 07:56:02 +01:00
Subject.Insert(sampleType);
Subject.All().Should().HaveCount(1);
Subject.Delete(sampleType.Id);
Subject.All().Should().BeEmpty();
}
[Test]
public void should_be_able_to_find_by_id()
{
2013-02-19 07:56:02 +01:00
Subject.Insert(sampleType);
Subject.Get(sampleType.Id)
.ShouldHave()
.AllProperties()
.EqualTo(sampleType);
}
[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();
}
}
}