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 { [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("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("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); } } }