public async Task Generate_GivenTableWithTableAndColumnComments_GeneratesExpectedOutput() { const string tableComment = "This is a test table comment for EF Core"; const string columnComment = "This is a test column comment for EF Core"; var tables = await Database.GetAllTables().ToListAsync().ConfigureAwait(false); var table = await GetTable("test_table_5").ConfigureAwait(false); var generator = TableGenerator; var comment = new RelationalDatabaseTableComments("test_table_5", Option <string> .Some(tableComment), Option <string> .None, new Dictionary <Identifier, Option <string> > { ["test_column_1"] = Option <string> .Some(columnComment) }, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup ); var result = generator.Generate(tables, table, comment); var expected = TestTable5Output; Assert.That(result, Is.EqualTo(expected).Using(LineEndingInvariantStringComparer.Ordinal)); }
public async Task Generate_GivenMultiLineTableWithForeignKeyComments_GeneratesExpectedOutput() { const string tableComment = @"This is a test table comment for EF Core. This is a second line for it."; const string foreignKeyComment = @"This is a test foreign key comment for EF Core. This is a second line for it."; var tables = await Database.GetAllTables().ToListAsync().ConfigureAwait(false); var table = await GetTable("test_table_7").ConfigureAwait(false); var generator = TableGenerator; var comment = new RelationalDatabaseTableComments("test_table_7", Option <string> .Some(tableComment), Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, new Dictionary <Identifier, Option <string> > { ["fk_test_table_7_test_table_6_fk1"] = Option <string> .Some(foreignKeyComment) }, Empty.CommentLookup, Empty.CommentLookup ); var result = generator.Generate(tables, table, comment); var expected = TestTable7MultiLineOutput; Assert.That(result, Is.EqualTo(expected).Using(LineEndingInvariantStringComparer.Ordinal)); }
public static void TriggerComments_PropertyGetWhenCtorGivenDictionaryWithValues_MatchesKeys() { var triggerNames = new[] { new Identifier("test_trigger_1"), new Identifier("test_trigger_2"), new Identifier("test_trigger_3") }; var triggerComments = new Dictionary <Identifier, Option <string> > { [triggerNames[0]] = Option <string> .None, [triggerNames[1]] = Option <string> .None, [triggerNames[2]] = Option <string> .None }; var comments = new RelationalDatabaseTableComments( "test_table", Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, triggerComments ); var propTriggerComments = comments.TriggerComments; Assert.That(triggerComments.Keys, Is.EqualTo(propTriggerComments.Keys)); }
public static void IndexComments_PropertyGetWhenCtorGivenDictionaryWithValues_MatchesKeys() { var indexNames = new[] { new Identifier("test_ix_1"), new Identifier("test_ix_2"), new Identifier("test_ix_3") }; var indexComments = new Dictionary <Identifier, Option <string> > { [indexNames[0]] = Option <string> .None, [indexNames[1]] = Option <string> .None, [indexNames[2]] = Option <string> .None }; var comments = new RelationalDatabaseTableComments( "test_table", Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, indexComments, Empty.CommentLookup ); var propIndexComments = comments.IndexComments; Assert.That(propIndexComments.Keys, Is.EqualTo(indexComments.Keys)); }
public static void TriggerComments_PropertyGetWhenCtorGivenEmptyDictionary_IsEmpty() { var comments = new RelationalDatabaseTableComments( "test_table_for_triggers", Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup ); Assert.That(comments.TriggerComments, Is.Empty); }
public static void PrimaryKeyComment_PropertyGetWhenCtorGivenNone_IsNone() { var comments = new RelationalDatabaseTableComments( "test_table_valid_name", Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup ); Assert.That(comments.Comment, OptionIs.None); }
public static void TableName_PropertyGet_EqualsCtorArg() { Identifier tableName = "test_table"; var comments = new RelationalDatabaseTableComments( tableName, Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup ); Assert.That(comments.TableName, Is.EqualTo(tableName)); }
public static void PrimaryKeyComment_PropertyGetWhenCtorGivenValidCommentValue_MatchesCommentValue() { const string commentText = "this is a test comment"; var commentArg = Option <string> .Some(commentText); var comments = new RelationalDatabaseTableComments( "test_table", Option <string> .None, commentArg, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup ); Assert.That(comments.PrimaryKeyComment.UnwrapSome(), Is.EqualTo(commentText)); }
public static void TriggerComments_PropertyGetWhenCtorGivenDictionaryWithValues_ContainsExpectedValues() { var triggerNames = new[] { new Identifier("test_trigger_1"), new Identifier("test_trigger_2"), new Identifier("test_trigger_3") }; var triggerComments = new Dictionary <Identifier, Option <string> > { [triggerNames[0]] = Option <string> .None, [triggerNames[1]] = Option <string> .Some("test comment for second trigger"), [triggerNames[2]] = Option <string> .Some("test comment for third trigger") }; var comments = new RelationalDatabaseTableComments( "test_table", Option <string> .None, Option <string> .None, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, Empty.CommentLookup, triggerComments ); var propTriggerComments = comments.TriggerComments; Assert.Multiple(() => { Assert.That(triggerComments.Keys, Is.EqualTo(propTriggerComments.Keys)); Assert.That(triggerComments["test_trigger_1"].IsNone, Is.EqualTo(propTriggerComments["test_trigger_1"].IsNone)); Assert.That(triggerComments["test_trigger_2"].IsNone, Is.EqualTo(propTriggerComments["test_trigger_2"].IsNone)); Assert.That(triggerComments["test_trigger_3"].IsNone, Is.EqualTo(propTriggerComments["test_trigger_3"].IsNone)); Assert.That(triggerComments["test_trigger_2"].UnwrapSome(), Is.EqualTo(propTriggerComments["test_trigger_2"].UnwrapSome())); Assert.That(triggerComments["test_trigger_3"].UnwrapSome(), Is.EqualTo(propTriggerComments["test_trigger_3"].UnwrapSome())); }); }