You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/src/NzbDrone.Core.Test/Datastore/Migration/122_add_remux_qualities_in_...

59 lines
2.4 KiB

using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class add_remux_qualities_in_profileFixture : MigrationTest<add_remux_qualities_in_profile>
{
[Test]
public void should_add_remux_to_old_profile()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Id = 0,
Name = "Bluray",
Cutoff = 7,
Items = "[ { \"quality\": 7, \"allowed\": true }, { \"quality\": 19, \"allowed\": true } ]"
});
});
var profiles = db.Query<Profile122>("SELECT \"Items\" FROM \"Profiles\" LIMIT 1");
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().Equal(7, 20, 19, 21);
items.Select(v => v.Allowed).Should().Equal(true, false, true, false);
items.Select(v => v.Name).Should().Equal(null, null, null, null);
}
[Test]
public void should_add_remux_to_old_profile_with_groups()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Id = 0,
Name = "Bluray",
Cutoff = 7,
Items = "[ { \"id\": 1001, \"name\": \"Why?!\", \"allowed\": true, \"items\": [{ \"quality\": 8, \"allowed\": true }, { \"quality\": 7, \"allowed\": true }] }, { \"quality\": 19, \"allowed\": true } ]"
});
});
var profiles = db.Query<Profile122>("SELECT \"Items\" FROM \"Profiles\" LIMIT 1");
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().Equal(null, 20, 19, 21);
items.Select(v => v.Allowed).Should().Equal(true, false, true, false);
items.Select(v => v.Name).Should().Equal("Why?!", null, null, null);
}
}
}