diff --git a/Libraries/MigSharp.dll b/Libraries/MigSharp.dll
new file mode 100644
index 000000000..d0c265902
Binary files /dev/null and b/Libraries/MigSharp.dll differ
diff --git a/Libraries/MigSharp.xml b/Libraries/MigSharp.xml
new file mode 100644
index 000000000..1dc15a3fc
--- /dev/null
+++ b/Libraries/MigSharp.xml
@@ -0,0 +1,1335 @@
+
+
+
+ MigSharp
+
+
+
+
+ Represents a type that knows how to provide database-specific DDL statements.
+
+
+
+
+ Checks whether a user created table exists on the database. The returned SQL command must yield 0 if the table does not exist.
+
+ The database name.
+ The table name.
+ The SQL command to be executed.
+
+
+
+ Converts an object to its SQL representation for scripting.
+
+
+
+
+ Creates a tables with the specified
+
+ The name of the new table.
+ The columns of the new table.
+ Empty if there are no primary key columns.
+ The SQL commands to be executed.
+
+
+
+ Drops a table.
+
+ The SQL commands to be executed.
+
+
+
+ Adds columns to an existing table.
+
+ The SQL commands to be executed.
+
+
+
+ Renames an existing table.
+
+ The SQL commands to be executed.
+
+
+
+ Renames a column of an existing table.
+
+ The SQL commands to be executed.
+
+
+
+ Removes a column from an existing table.
+
+ The SQL commands to be executed.
+
+
+
+ Changes the data type of a column.
+
+ The SQL commands to be executed.
+
+
+
+ Adds an index to a table.
+
+ The SQL commands to be executed.
+
+
+
+ Drops an index from a table.
+
+ The SQL commands to be executed.
+
+
+
+ Adds a foreign key constraint to a table.
+
+ The SQL commands to be executed.
+
+
+
+ Drops a foreign key constraint from a table.
+
+ The SQL commands to be executed.
+
+
+
+ Adds a primary key constraint to a table.
+
+ The SQL commands to be executed.
+
+
+
+ Renames the primary key.
+
+ The SQL commands to be executed.
+
+
+
+ Drops a primary key constraint from a table.
+
+ The SQL commands to be executed.
+
+
+
+ Adds an unique constraint to a table.
+
+ The SQL commands to be executed.
+
+
+
+ Drops a unique constraint from a table.
+
+ The SQL commands to be executed.
+
+
+
+ Drops the default value (constraint) from a column.
+
+ The SQL commands to be executed.
+
+
+
+ Represents the main entry point to perform migrations.
+
+
+
+
+ Initializes a new instance of .
+
+ Connection string to the database to be migrated.
+ The name of the provider that should be used for this migrator ().
+ Options.
+
+
+
+ Initializes a new instance of for a specific module.
+
+ Connection string to the database to be migrated.
+ The name of the provider that should be used for this migrator ().
+ The name of the module whose migrations should be executed.
+
+
+
+ Initializes a new instance of with default options.
+
+ Connection string to the database to be migrated.
+ The name of the provider that should be used for this migrator ().
+
+
+
+ Executes all pending migrations found in .
+
+ The assembly to search for migrations.
+ Optional assemblies that hold additional migrations.
+
+
+
+ Executes all migrations required to reach .
+
+
+
+ Optional assemblies that hold additional migrations.
+
+
+
+ Retrieves all pending migrations.
+
+ The assembly that contains the migrations.
+ Optional assemblies that hold additional migrations.
+
+
+
+ Retrieves all required migrations to reach .
+
+ The assembly that contains the migrations.
+ The timestamp to migrate to.
+ When the migration path would require downgrading a migration which is not reversible.
+ Optional assemblies that hold additional migrations.
+
+
+
+ Checks if any migrations are pending to be performed.
+
+ The assembly that contains the migrations.
+ Optional assemblies that hold additional migrations.
+
+
+
+ Injects a custom version mechanism.
+
+
+
+
+ Injects a custom bootstrapping mechanism.
+
+
+
+
+ Represents a database.
+
+
+
+
+ Creates a new table on the database.
+
+ The name of the new table.
+ Optionally, the name of the primary key constraint.
+
+
+
+ Executes a custom query.
+
+ Custom SQL which must be understood by all providers that should be supported by this migration.
+
+
+
+ Executes a custom action against the . Use this method if you need to directly access the
+ underlying or .
+
+
+
+
+ Gets the context of the migration.
+
+
+
+
+ Gets existing tables.
+
+
+
+
+ Contains the extension methods for the interface.
+
+
+
+
+ Creates a new table on the database with a default primary key constraint name.
+
+
+
+
+ Represents the context of a migration.
+
+
+
+
+ Gets the metadata describing the underlying provider.
+
+
+
+
+ Represents an index.
+
+
+
+
+ Drops the index.
+
+
+
+
+ Represents an index which is about to be added to a table.
+
+
+
+
+ Adds the index on the provided column.
+
+
+
+
+ Represents a primary key constraint which is about to be added to a table.
+
+
+
+
+ Adds the index on the provided column.
+
+
+
+
+ Represents a batch of s.
+
+
+
+
+ Performs the migrations contained in this batch.
+
+
+
+
+ Raised before each migration that will be executed.
+
+
+
+
+ Raised after each migration that has been executed.
+
+
+
+
+ Gets the number of migrations in this batch.
+
+
+
+
+ Gets a list of s that were used to create new objects (excluding primary key columns).
+
+
+
+
+ Gets a list of s that were used to create primary key columns.
+
+
+
+
+ Gets a list of names of any created objects.
+
+
+
+
+ Gets a list of method names that were used for the migration.
+
+
+
+
+ Represents a collection of existing indexes of a table.
+
+
+
+
+ Gets an index by name.
+
+
+
+
+ Represents an unique constraint.
+
+
+
+
+ Drops the unique constraint.
+
+
+
+
+ Represents a foreign key constraint.
+
+
+
+
+ Drops the foreign key constraint.
+
+
+
+
+ Executes the migration step and updates the versioning information in one transaction.
+
+ Might be null in the case of a bootstrap step.
+
+
+
+ Executes the migration step and updates the versioning information in one transaction.
+
+
+
+
+ Represents a pair of column names which is used as an element of a foreign key relationship.
+
+
+
+
+ Gets the name of the referencing column.
+
+
+
+
+ Gets the name of the referenced column.
+
+
+
+
+ Represents the version of a database containing all information about past migrations.
+
+
+
+
+ Verifies if a specific migration was executed.
+
+ It might seems odd that this method does not receive a connection. However, the idea is that the object implementing
+ this interface initializes itself once upon construction and the answers the calls to this method from a cache.
+ Thus, it would not need to do any round-trip to the database which is important as this method is called for each migration.
+
+
+
+
+
+ Updates the versioning to include or exclude the migration depending on the provided .
+
+ Post-condition: if was , must return true.
+ Otherwise was and must return false.
+
+
+ The metadata of the migration to be included in the versioning table.
+ An open connection to the database containing the versioning table.
+ The associated transaction.
+ The direction of the migration.
+ Used to execute s.
+
+
+
+ Represents a created table.
+
+
+
+
+ Represents a created table.
+
+
+
+
+ Adds a non-nullable column which is part of the primary key constraint to the table being created.
+
+
+
+
+ Adds a non-nullable column to the table being created.
+
+
+
+
+ Adds a nullable column to the table being created.
+
+
+
+
+ Gets the name of the table.
+
+
+
+
+ Represents a unique constraint which is about to be added to a table.
+
+
+
+
+ Adds the unique constraint on the provided column.
+
+
+
+
+ Declares the support of a specific data type.
+
+
+
+
+ Initializes a new instance.
+
+
+
+
+ Gets the supported data type.
+
+
+
+
+ Gets or sets the maximum length for character data types or the maximum total number of decimal digits for numeric data types.
+
+
+
+
+ Gets or sets the maximum number of decimal digits that can be stored to the right of the decimal point. Scale is a value from 0 through .
+
+
+
+
+ Indicates if the data type can be used in primary key columns. By default, this is false.
+
+
+
+
+ Gets or sets a warning message if there are any restrictions when using this .
+ The warning message is logged when executing a migration containing this data type.
+
+
+
+
+ Indicates if the data type can be scripted.
+
+
+
+
+ Represents an added column on an existing table.
+
+
+
+
+ Represents a table that was created before.
+
+
+
+
+ Adds a not-nullable column.
+
+
+
+
+ Adds a nullable column.
+
+
+
+
+ Gets the name of the table.
+
+
+
+
+ Specifies the size and the scale of the data type of the column.
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+ The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through .
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Adds a default value to the column which is dropped after adding the column to the table.
+ Use this method to fill a non-nullable column with default values.
+
+
+
+
+ Adds a default value to the column which is dropped after adding the column to the table.
+ Use this method to fill a non-nullable column with default values.
+
+
+
+
+ Contains the extensions methods for the interface.
+
+
+
+
+ Specifies the size of the data type of the column.
+
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+
+
+
+ Sets the default of the column to be the current system time of the database server.
+
+
+
+
+ Reperesents metadata about an .
+
+
+
+
+ Gets the unique name of this provider.
+
+
+
+
+ Gets the invariant name of the provider needed for .
+
+
+
+
+ Gets an indication if the underlying provider supports transactions.
+
+
+
+
+ Gets an expression that specifies how s are addressed in command texts. The literal 'p' is replaced by the parameter name.
+
+
+
+
+ Gets the maximum length of object names within the database. 0 meaning that there is non restriction which is the default.
+
+
+
+
+ Represents a column on a newly created table.
+
+
+
+
+ Specifies the size and the scale of the data type of the column.
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+ The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through .
+
+
+
+ Puts the column under an unique constraint.
+
+ Optionally, specify the name of the unique constraint. If null or empty, a default constraint name will be generated.
+
+
+
+ Makes the column auto-increment.
+
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Gets the column name.
+
+
+
+
+ This exception is thrown when a requested downgrade path contains an irreversible migration.
+
+
+
+
+ Contains the names of the supported providers.
+
+
+
+
+ Represents the run-time context of a migration.
+
+
+
+
+ Gets the connection which is used to perform the migration.
+
+
+
+
+ Gets the transaction which is used to perform the migration.
+
+
+
+
+ Gets the that should be used to execute database modifying commands.
+ This ensures that they are logged and scripted consistently.
+
+
+
+
+ Lists special default values for columns.
+
+
+
+
+ Represents the current date time of the database server.
+
+
+
+
+ Represents a collection of providers that should be supported for all migrations. Validation of migrations is performed
+ against providers contained within this list.
+
+
+
+
+ Initializes a new instance used for unit testing.
+
+
+
+
+ Initializes a new instance which is ready-to-use with the default providers.
+
+
+
+
+ Adds a provider.
+
+
+
+
+ Removes a provider.
+
+
+
+
+ Removes all ODBC providers.
+
+
+
+
+ Sets the collection to a list of providers.
+
+
+
+
+ Resets the collection to support all providers that are delivered with Mig#.
+
+
+
+
+ Gets the names of the providers.
+
+
+
+
+ Represents a collection of existing unique constraints of a table.
+
+
+
+
+ Gets an unique constraint by name.
+
+
+
+
+ Use this attribute to mark classes as migrations.
+
+
+
+
+ The maximum string length for a module name.
+
+
+
+
+ Initializes a new instance of the attribute.
+
+
+
+
+ Gets the name of the module to which this migration belongs to (see also ).
+
+
+
+
+ Gets the tag associated with this migration.
+
+
+
+
+ Represents a migration that can also be downgraded.
+
+
+
+
+ The interface that needs to be implemented in order to define a migration.
+ Additionally, the must be applied
+ to a class implementing this interface in order to be recognized as a migration.
+
+
+
+
+ Applies the required changes to the provided for this migration.
+
+
+
+
+ Undoes all changes from the method.
+
+
+
+
+ Represents a foreign key constraint which is about to be added to a table.
+
+
+
+
+ Specifies the columns on which the foreign key is defined.
+
+
+ This method is not called 'On', as 'On' is a reserved language keyword (see FxCop rule "Identifiers should not match keywords").
+
+
+
+
+ Contains information about used data types, longest name, etc. for a specific migration.
+
+
+
+
+ Gets the full type name of the migration for this report.
+
+
+
+
+ Gets the error message for the migration if there was an .
+
+
+
+
+ Gets a list of s that were used to create new objects (including primary key columns).
+
+
+
+
+ Gets a list of s that were used to create primary key columns.
+
+
+
+
+ Gets the longest name of any created objects.
+
+
+
+
+ Gets a list of used provider method names.
+
+
+
+
+ Marks the class as an provider implementing .
+
+
+
+
+ Initializes a new instance.
+
+
+
+
+ Gets the unique name of this provider.
+
+
+
+
+ Gets the invariant name of the provider needed for .
+
+
+
+
+ Gets or sets an indication if the underlying provider supports transactions. True by default.
+
+
+
+
+ Gets an expression that specifies how s are addressed in command texts. The literal 'p' is replaced by the parameter name.
+ The default is '@p'.
+
+
+
+
+ Gets or sets the maximum length of object names within the database. 0 meaning that there is non restriction which is the default.
+
+
+
+
+ Represents a collection of existing foreign key constraints of a table.
+
+
+
+
+ Gets an foreign key constraint by name.
+
+
+
+
+ Represents an existing column whose data type is being altered.
+
+
+
+
+ Specifies the size and the scale of the new data type of the column.
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+ The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through .
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Adds a default value to the column.
+
+
+
+
+ Contains the extensions methods for the interface.
+
+
+
+
+ Specifies the size of the new data type of the column.
+
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+
+
+
+ Sets the default of the column to be the current system time of the database server.
+
+
+
+
+ MigSharp provider for Microsoft SQL Compact Edition 4.0.
+
+
+
+
+ Represents a collection of existing tables.
+
+
+
+
+ Gets a table by its name.
+
+
+
+
+ Represents a collection of existing columns.
+
+
+
+
+ Gets a column by its name.
+
+
+
+
+ Represents an existing column.
+
+
+
+
+ Renames the column.
+
+
+
+
+ Removes the column from its table.
+
+
+
+
+ Alters the column to be a nullable column.
+
+ A new or the old data type of the column.
+
+
+
+ Alters the column to be a nullable column.
+
+ A new or the old data type of the column.
+
+
+
+ Gets the name of the column.
+
+
+
+
+ Gets the name of the table of the column.
+
+
+
+
+ Contains the extensions methods for the interface.
+
+
+
+
+ Specifies the size of the data type of the column.
+
+
+ The length for character data types or the maximum total number of decimal digits for numeric data types.
+
+
+
+ Puts the column under an unique constraint with a default constraint name.
+
+
+
+
+ Sets the default of the column to be the current system time of the database server.
+
+
+
+
+ Visits all commands executed against a and translates them into SQL
+ using a specific .
+
+
+
+
+ Translates the recorded commands on the to SQL commands.
+
+
+
+
+ Represents a SQL data type.
+
+
+
+
+ Initializes a new instance of .
+
+
+
+
+ Used in validation messages and for debugging.
+
+
+
+
+ Gets the length for character data types or the maximum total number of decimal digits for numeric data types.
+
+
+
+
+ Gets the maximum number of decimal digits that can be stored to the right of the decimal point. Scale is a value from 0 through .
+
+
+
+
+ Use this class to configure the behaviour of the .
+
+
+
+
+ Initializes an instance of default options.
+
+
+
+
+ Initializes options that select migrations for specific module only.
+
+ The name of the selected module. Only migrations for this module will be executed.
+
+
+
+ Suppresses validation warnings for the provider called and the data type under the .
+
+
+
+
+ Outputs the SQL used for the migrations to external files without affecting the database.
+
+
+
+
+ Outputs the SQL used for the migrations to external files without affecting the database.
+
+
+
+
+ Outputs the SQL used for the migrations to external files while migrating the database.
+
+
+
+
+ Outputs the SQL used for the migrations to external files while migrating the database.
+
+
+
+
+ Sets the level of general information being traced.
+
+
+
+
+ Sets the level of SQL information being traced.
+
+
+
+
+ Sets the level of performance information being traced.
+
+
+
+
+ Gets or sets the table name of the versioning table.
+
+
+
+
+ Gets the providers that should be supported for all migrations. Compatibility validation of migrations is performed
+ against the providers in this collection.
+
+
+
+
+ Gets or sets a function that selects the module based on its name. Only migrations for this module will be executed.
+
+
+
+
+ Expresses under which circumstances a warning should be expressed for a given and its OfSize parameters.
+
+
+
+
+ Suppresses all warnings for the specified . Use diligently.
+
+
+
+
+ Suppresses warnings for the specified when it is used without a specified size.
+
+
+
+
+ Suppresses warnings for the specified when it is used with a specified size.
+
+
+
+
+ Suppresses warnings for the specified when it is used with a specified size and a specified scale.
+
+
+
+
+ Validates s against the list of supported providers.
+
+
+
+
+ Represents a table that was created before.
+
+
+
+
+ Gets the primary key constraint of the table.
+
+ Optionally, the name of the primary key constraint. If null or empty, the default name will be used.
+
+
+
+ Renames the table.
+
+
+
+
+ Drops the table.
+
+
+
+
+ Adds a primary key constraint to the table.
+
+ Optionally, the primary key constraint name. If null or empty, a default name will be generated.
+
+
+
+ Adds an index to the table.
+
+ Optionally, the index name. If null or empty, a default name will be generated.
+
+
+
+ Adds a foreign key constraint to another table.
+
+ The name of the referenced table.
+ Optionally, the name of the foreign key constraint. If null or empty, a default name will be generated.
+
+
+
+ Adds an unique constraint to the table.
+
+ Optionally, the name of the unique constraint. If null or empty, a default name will be generated.
+
+
+
+ Gets the columns of the table.
+
+
+
+
+ Gets the unique constraints of the table.
+
+
+
+
+ Gets the unique constraints of the table.
+
+
+
+
+ Gets the foreign key constraints of the table.
+
+
+
+
+ Represents a primary key constraint.
+
+
+
+
+ Drops the primary key constraint.
+
+
+
+
+ Renames the primary key constraint and all associated resources (e.g. Oracle maintains an index along with the primary key which is renamed, too).
+
+
+
+
+
+ Returns the longer string.
+
+
+
+
+ Returns the longest string.
+
+
+
+
+ Creates a name with the following structure: '_[0]_[1]_..._'.
+ The contained names are shortened such that the complete generated name fits characters.
+
+ The table name.
+ The postfix to be appended to the name. The postfix will *not* be shortened in any way.
+ The maximum length of the generated name.
+ Additional names that should be included in the result which follow the table name.
+
+
+
+ Event arguments for migration events.
+
+
+
+
+ Initializes a new instance.
+
+
+
+
+ Gets the associated metadata.
+
+
+
+
+ Gets the direction of the migration step.
+
+
+
+
+ Implements a custom bootstrapping logic which is executed if the versioning table of MigSharp doe not exists yet.
+
+
+
+
+ Triggers whatever actions are needed to prepare the custom bootstrapping. This method is called exactly once,
+ before is called any times.
+
+ The connection used to update the versioning table.
+ The transaction used to update the versioning table.
+
+
+
+ Returns true if the migration should be assumed as already executed when bootstrapping the versioning.
+
+
+
+
+ Triggers whatever actions are needed to finish the custom bootstrapping. This method is called exactly once,
+ after is called any times.
+
+ The connection used to update the versioning table.
+ The transaction used to update the versioning table.
+
+
+
+ Contains extension methods for the interface.
+
+
+
+
+ Gets the primary key constraint of the table with the default name.
+
+
+
+
+ Adds a primary key constraint to the table with the default name.
+
+
+
+
+ Adds an index to the table.
+
+
+
+
+ Adds a foreign key constraint to another table with the default name.
+
+
+ The name of the referenced table.
+
+
+
+ Adds an unique constraint to the table with the default name.
+
+
+
+
+ Gets an unique constraint by the name of its first column.
+
+
+
+
+ Gets an foreign key constraint by the name of its referenced table.
+
+
+
+
+ Implements without creating a versioning table until it is really needed.
+
+
+
+
diff --git a/NzbDrone.Core.Test/App.config b/NzbDrone.Core.Test/App.config
index 6e63be8ce..0d29e6625 100644
--- a/NzbDrone.Core.Test/App.config
+++ b/NzbDrone.Core.Test/App.config
@@ -19,5 +19,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/EpisodeProviderTest.cs b/NzbDrone.Core.Test/EpisodeProviderTest.cs
index abd537fca..2cbc2bb00 100644
--- a/NzbDrone.Core.Test/EpisodeProviderTest.cs
+++ b/NzbDrone.Core.Test/EpisodeProviderTest.cs
@@ -13,6 +13,7 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
+using PetaPoco;
using SubSonic.Repository;
using TvdbLib.Data;
@@ -22,6 +23,29 @@ namespace NzbDrone.Core.Test
// ReSharper disable InconsistentNaming
public class EpisodeProviderTest : TestBase
{
+
+ [Test]
+ public void GetEpisodesBySeason_success()
+ {
+ var episodes = Builder.CreateListOfSize(10)
+ .WhereAll().Have(c => c.SeriesId = 12)
+ .WhereTheFirst(5).Have(c => c.SeasonNumber = 1)
+ .AndTheRemaining().Have(c => c.SeasonNumber = 2).Build();
+
+ var db = MockLib.GetEmptyDatabase();
+ var mocker = new AutoMoqer();
+ mocker.SetConstant(db);
+
+ episodes.ToList().ForEach(c => db.Insert(c));
+
+ //Act
+ var seasonEposodes = mocker.Resolve().GetEpisodesBySeason(12, 2);
+
+ //Assert
+ db.Fetch().Should().HaveCount(10);
+ seasonEposodes.Should().HaveCount(5);
+ }
+
[Test]
public void RefreshEpisodeInfo_emptyRepo()
{
@@ -42,7 +66,7 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer();
- mocker.SetConstant(MockLib.GetEmptyRepository());
+ mocker.SetConstant(MockLib.GetEmptyDatabase());
mocker.GetMock()
.Setup(c => c.GetSeries(seriesId, true))
@@ -61,65 +85,72 @@ namespace NzbDrone.Core.Test
[Test]
- public void new_episodes_only_calls_AddMany()
+ public void new_episodes_only_calls_Insert()
{
const int seriesId = 71663;
- var fakeEpisodes = Builder.CreateNew()
+ var tvdbSeries = Builder.CreateNew()
.With(c => c.Episodes = new List(Builder.CreateListOfSize(5).Build())
).With(c => c.Id = seriesId).Build();
var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build();
+ var currentEpisodes = new List();
+
var mocker = new AutoMoqer();
mocker.GetMock(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true))
- .Returns(fakeEpisodes);
+ .Returns(tvdbSeries);
+
+ mocker.GetMock()
+ .Setup(d => d.Fetch(It.IsAny(), It.IsAny