public void VerifyWronglyUsedOfSizeAreReported() { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.Int32, 777), false, false), new UsedDataType(new DataType(DbType.String, null, 777), false, false), new UsedDataType(new DataType(DbType.Decimal), false, false), }; IRecordedMigration migration = A.Fake <IRecordedMigration>(); A.CallTo(() => migration.DataTypes).Returns(dataTypes); //migration.Expect(m => m.Methods).Return(Enumerable.Empty<string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(777)' which is not supported by '{2}'.", MigrationName, DbType.Int32, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(null,777)' which is not supported by '{2}'.", MigrationName, DbType.String, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}' which is not supported by '{2}'.", MigrationName, DbType.Decimal, Platform), errors); Assert.That(warnings, Is.Null.Or.Empty); }
public void VerifyUnsupportedDataTypesAreReported() { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.String, 255), false, false), // ok new UsedDataType(new DataType(DbType.Currency), false, false), // not supported new UsedDataType(new DataType(DbType.Int32), false, false), // ok new UsedDataType(new DataType(DbType.Decimal, 20, 10), false, false), // exceeds size and scale new UsedDataType(new DataType(DbType.String), false, false), // ok (should not override the primary key status of this DbType) new UsedDataType(new DataType(DbType.String), true, false), // as primary key -> *not* ok w/o size new UsedDataType(new DataType(DbType.String, 255), true, false), // as primary key -> ok new UsedDataType(new DataType(DbType.Decimal, 8, 2), false, true), // as identity -> *not* ok with scale new UsedDataType(new DataType(DbType.Decimal, 8), false, true), // as identity -> ok without scale }; IRecordedMigration migration = A.Fake <IRecordedMigration>(); A.CallTo(() => migration.DataTypes).Returns(dataTypes); //migration.Expect(m => m.Methods).Return(Enumerable.Empty<string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); string expected = string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}' which is not supported by '{2}'.", MigrationName, DbType.Currency, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(20,10)' which exceeds the maximum size of 10 supported by '{2}'.", MigrationName, DbType.Decimal, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(20,10)' which exceeds the maximum scale of 5 supported by '{2}'.", MigrationName, DbType.Decimal, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}' for a primary key which is not supported by '{2}'.", MigrationName, DbType.String, Platform) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(8,2)' for an identity column which is not supported by '{2}'.", MigrationName, DbType.Decimal, Platform); Assert.AreEqual(expected, errors); }
public void VerifyWronglyUsedOfSizeAreReported() { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.Int32, 666, 0), false, false), new UsedDataType(new DataType(DbType.String, 0, 666), false, false), new UsedDataType(new DataType(DbType.Decimal, 0, 0), false, false), }; IRecordedMigration migration = MockRepository.GenerateStub <IRecordedMigration>(); migration.Expect(m => m.DataTypes).Return(dataTypes); migration.Expect(m => m.Methods).Return(Enumerable.Empty <string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(666)' with a non-zero size and a zero scale which is not supported by '{2}'.", MigrationName, DbType.Int32, ProviderName) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}(0,666)' with a zero size and a non-zero scale which is not supported by '{2}'.", MigrationName, DbType.String, ProviderName) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}' with a zero size and a zero scale which is not supported by '{2}'.", MigrationName, DbType.Decimal, ProviderName), errors); Assert.IsNullOrEmpty(warnings); }
public MigrationReport(string migrationName, string error, IRecordedMigration migration) { _migrationName = migrationName; _longestName = migration.NewObjectNames.Longest(); _error = error; _dataTypes.AddRange(migration.DataTypes); _methods.AddRange(migration.Methods); }
public void VerifyUnsupportedMethodsAreReported() { IRecordedMigration migration = A.Fake <IRecordedMigration>(); //migration.Expect(m => m.DataTypes).Return(Enumerable.Empty<UsedDataType>()); A.CallTo(() => migration.Methods).Returns(new[] { "CreateTable", "AddColumn" }); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Migration '{0}' calls the '{1}' method which is not supported by '{2}': AddColumn is not supported because this is just a test.", MigrationName, "AddColumn", Platform), errors); Assert.That(warnings, Is.Null.Or.Empty); }
private static string GetWarnings(IEnumerable <ProviderInfo> providerInfos, MigrationOptions options, out string warnings) { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.Guid), false, false), new UsedDataType(new DataType(DbType.String), false, false), }; IRecordedMigration migration = A.Fake <IRecordedMigration>(); A.CallTo(() => migration.DataTypes).Returns(dataTypes); //migration.Expect(m => m.Methods).Return(Enumerable.Empty<string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; Validate(providerInfos, options, report, out errors, out warnings); return(errors); }
public void VerifyUnsupportedMethodsAreReported() { IRecordedMigration migration = MockRepository.GenerateStub <IRecordedMigration>(); migration.Expect(m => m.DataTypes).Return(Enumerable.Empty <UsedDataType>()); migration.Expect(m => m.Methods).Return(new[] { "CreateTable", "DropTable" }); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Migration '{0}' calls the '{1}' method which is not supported by '{2}': DropTable is not supported because this is just a test.", MigrationName, "DropTable", ProviderName), errors); Assert.IsNullOrEmpty(warnings); }
private static string GetWarnings(MigrationOptions options, out string warnings) { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.Guid, 0, 0), false, false), new UsedDataType(new DataType(DbType.String, 0, 0), false, false), }; IRecordedMigration migration = MockRepository.GenerateStub <IRecordedMigration>(); migration.Expect(m => m.DataTypes).Return(dataTypes); migration.Expect(m => m.Methods).Return(Enumerable.Empty <string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; Validate(options, report, out errors, out warnings); return(errors); }
public void VerifyViolatingMaximumDbObjectNameLengthIsReported() { const string longestName = "Some very long name"; IRecordedMigration migration = A.Fake <IRecordedMigration>(); A.CallTo(() => migration.NewObjectNames).Returns(new[] { longestName, longestName.Substring(1) }); //A.CallTo(() => migration.DataTypes).Returns(Enumerable.Empty<UsedDataType>()); //migration.Expect(m => m.Methods).Return(Enumerable.Empty<string>()); var report = new MigrationReport(MigrationName, "Some other validation error.", migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Error in migration '{0}': Some other validation error.", MigrationName) + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, "Migration '{0}' contains object names that are longer than what is supported by '{1}' ('{2}': {3}, supported: {4}).", MigrationName, Platform, longestName, longestName.Length, MaximumSupportedLength), errors); Assert.That(warnings, Is.Null.Or.Empty); }
public void VerifyWarningsForOdbc() { var dataTypes = new List <UsedDataType> { new UsedDataType(new DataType(DbType.Int64), false, false), }; IRecordedMigration migration = A.Fake <IRecordedMigration>(); A.CallTo(() => migration.DataTypes).Returns(dataTypes); //migration.Expect(m => m.Methods).Return(Enumerable.Empty<string>()); MigrationReport report = new MigrationReport(MigrationName, string.Empty, migration); string errors; string warnings; Validate(report, out errors, out warnings); Assert.That(errors, Is.Null.Or.Empty); Assert.AreEqual( string.Format(CultureInfo.CurrentCulture, "Migration '{0}' uses the data type '{1}' which is not fully supported by '{2}': Int64 is not supported for DbParameters with ODBC; requires calling ToString to directly inline the value in the CommandText.", MigrationName, DbType.Int64, Platform), warnings); }