public Create(Interpreter interpreter, SchemaComparer schemaComparer, DataMigrator dataMigrator) { _interpreter = interpreter; _schemaComparer = schemaComparer; _dataMigrator = dataMigrator; }
public void TestMoreSpecific() { var comparer = new SchemaComparer(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific_base.json")), new SchemaComparisionReport()); Assert.IsNotNull(resultSchema); Assert.AreEqual("TestModel", resultSchema.Title, "Expected the title for the base schema"); SchemaAssertions.AssertSingleProperty(resultSchema, "name", JSchemaType.Integer); }
public void TestMoreSpecific() { var comparer = new SchemaComparer(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific_base.json")), new SchemaComparisionReport()); Assert.IsNotNull(resultSchema); Assert.AreEqual("TestModel", resultSchema.Title, "Expected the title for the base schema"); SchemaAssertions.AssertSingleProperty(resultSchema, "name", JSchemaType.Integer); }
public void TestMoreSpecific() { var comparer = new SchemaComparer(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/moreSpecific.json")), GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/moreSpecific_base.json")), new SchemaComparisionReport()); Assert.NotNull(resultSchema); Assert.Equal("TestModel", resultSchema.Title); SchemaAssertions.AssertSingleProperty(resultSchema, "name", JSchemaType.Integer); }
public void TestAnyPropertyFromBaseSchemaShouldBeTaken() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/anyPropertyInMoreSpecific.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/anyPropertyInMoreSpecific_base.json")), report); Assert.IsNotNull(resultSchema); Assert.AreEqual("val1", resultSchema.Properties["name"].Format); //Assert.AreEqual("TestModel", resultSchema.Properties["prop2"], "val2"); }
public void TestAnyPropertyFromBaseSchemaShouldBeTaken() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/anyPropertyInMoreSpecific.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/anyPropertyInMoreSpecific_base.json")), report); Assert.IsNotNull(resultSchema); Assert.AreEqual("val1", resultSchema.Properties["name"].Format); //Assert.AreEqual("TestModel", resultSchema.Properties["prop2"], "val2"); }
public void TestInfoOnMissingPropertyInBaseSchema() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/infoOnMissingPropertyInBaseSchema.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/infoOnMissingPropertyInBaseSchema_base.json")), report); var infos = report.GetInfos().ToList(); Assert.AreEqual(1, infos.Count, "one failure expected."); Assert.IsInstanceOfType(infos[0], typeof(MissingPropertyInfo), "Expected to be a MissingPropertyInfo"); Assert.AreEqual("missingPropertyInBase", ((MissingPropertyInfo)infos[0]).PropertyName); }
public void TestInvalidTypeChange() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/invalidTypeChangeInBase.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/invalidTypeChangeInBase_base.json")), report); var failures = report.GetFailures().ToList(); Assert.AreEqual(1, failures.Count, "one failure expected."); Assert.IsInstanceOfType(failures[0], typeof(TypeChangeFailure), "Expected to be a TypeChangeFailure"); Assert.AreEqual("name", ((TypeChangeFailure)failures[0]).PropertyName); }
public void TestInfoOnMissingPropertyInBaseSchema() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/infoOnMissingPropertyInBaseSchema.json")), GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/infoOnMissingPropertyInBaseSchema_base.json")), report); var infos = report.GetInfos().ToList(); Assert.Equal(1, infos.Count); Assert.IsType(typeof(MissingPropertyInfo), infos[0]); Assert.Equal("missingPropertyInBase", ((MissingPropertyInfo)infos[0]).PropertyName); }
public void TestInvalidTypeChange() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/invalidTypeChangeInBase.json")), GetSchema(Path.Combine(PathUtility.GetDirectory(), "Mocks/Comparisions/invalidTypeChangeInBase_base.json")), report); var failures = report.GetFailures().ToList(); Assert.Equal(1, failures.Count); Assert.IsType(typeof(TypeChangeFailure), failures[0]); Assert.Equal("name", ((TypeChangeFailure)failures[0]).PropertyName); }
public void TestInfoOnMissingPropertyInBaseSchema() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/infoOnMissingPropertyInBaseSchema.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/infoOnMissingPropertyInBaseSchema_base.json")), report); var infos = report.GetInfos().ToList(); Assert.AreEqual(1, infos.Count, "one failure expected."); Assert.IsInstanceOfType(infos[0], typeof(MissingPropertyInfo), "Expected to be a MissingPropertyInfo"); Assert.AreEqual("missingPropertyInBase", ((MissingPropertyInfo)infos[0]).PropertyName); }
public void TestInvalidTypeChange() { var comparer = new SchemaComparer(); var report = new SchemaComparisionReport(); var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/invalidTypeChangeInBase.json")), GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/invalidTypeChangeInBase_base.json")), report); var failures = report.GetFailures().ToList(); Assert.AreEqual(1, failures.Count, "one failure expected."); Assert.IsInstanceOfType(failures[0], typeof(TypeChangeFailure), "Expected to be a TypeChangeFailure"); Assert.AreEqual("name", ((TypeChangeFailure)failures[0]).PropertyName); }
public static void Compare(FlightInfo expected, FlightInfo actual) { //Check endpoints Assert.Equal(expected.Endpoints, actual.Endpoints); //Check flight descriptor Assert.Equal(expected.Descriptor, actual.Descriptor); //Check schema SchemaComparer.Compare(expected.Schema, actual.Schema); Assert.Equal(expected.TotalBytes, actual.TotalBytes); Assert.Equal(expected.TotalRecords, actual.TotalRecords); }
public async Task <JSchema> GetSchemaFromTemplateAsync(TemplateInfo template) { var comparer = new SchemaComparer(); var schema1Task = _schemaProvider.GetSchemaFromTemplateAsync(template); var schema2Task = _schemaBaseProvider.GetSchemaFromTemplateAsync(template); if (schema1Task == null) { return(await schema2Task); } if (schema2Task == null) { return(await schema1Task); } await Task.WhenAll(schema1Task, schema2Task).ConfigureAwait(false); return(comparer.Apply(schema1Task.Result, schema2Task.Result, new SchemaComparisionReport())); }
/// <summary> /// Actually runs the test. /// </summary> /// <returns>If false, call <see cref="MySqlHelper.AskToImportDatabase"/>.</returns> static bool TestInternal(out string errmsg) { var schema = LoadSchemaFile.Schema; if (schema == null) { errmsg = "Could not run test since the database schema file failed to load."; return(true); } SchemaReader userSchema; try { userSchema = new SchemaReader(MySqlHelper.ConnectionSettings); } catch (MySqlException ex) { errmsg = AppendErrorDetails("Failed to read the database schema from MySql. Error: " + ex.Message, ex.ToString()); return(false); } var diffs = SchemaComparer.Compare(schema, userSchema); const string failmsg2 = "\nOne or more differences were found in your database schema in comparison to" + " the release's database schema. If you have manually altered your database's schema (such as add" + " fields or alter field types), you can ignore this message. Otherwise, this likely means that you" + " are using the wrong database dump file for this version of NetGore. Often times, this is because" + " you have the database from an older version of NetGore that is not compatible with this version." + "\nTo resolve this issue, please use the database dump (db.sql) from this version of NetGore." + " Make sure to back up your database if you want to save any of the contents!" + "\n\nThe following is a list of all the differences found in your database schema: \n{0}"; errmsg = string.Format(failmsg2, ToNewLines(diffs)); return(diffs == null || diffs.Count() == 0); }
private async Task <int> Validate() { JsonFile jsonFile = await ParseJsonFile(); using FileStream arrowFileStream = ArrowFileInfo.OpenRead(); using ArrowFileReader reader = new ArrowFileReader(arrowFileStream); int batchCount = await reader.RecordBatchCountAsync(); if (batchCount != jsonFile.Batches.Count) { Console.WriteLine($"Incorrect batch count. JsonFile: {jsonFile.Batches.Count}, ArrowFile: {batchCount}"); return(-1); } Schema jsonFileSchema = CreateSchema(jsonFile.Schema); Schema arrowFileSchema = reader.Schema; SchemaComparer.Compare(jsonFileSchema, arrowFileSchema); for (int i = 0; i < batchCount; i++) { RecordBatch arrowFileRecordBatch = reader.ReadNextRecordBatch(); RecordBatch jsonFileRecordBatch = CreateRecordBatch(jsonFileSchema, jsonFile.Batches[i]); ArrowReaderVerifier.CompareBatches(jsonFileRecordBatch, arrowFileRecordBatch, strictCompare: false); } // ensure there are no more batches in the file if (reader.ReadNextRecordBatch() != null) { Console.WriteLine($"The ArrowFile has more RecordBatches than it should."); return(-1); } return(0); }