Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented SqlConnection.InfoMessage #24

Merged
merged 1 commit into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions DBMigrator.Test/DatabaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,17 @@ public void Versions_one_versions_test()
Assert.AreEqual("A", dbScript.Checksum);
Assert.AreNotEqual(dbScript.ExecutionTime, null);
}


[TestMethod]
public void Message_test()
{
var database = new Database(@"(localdb)\mssqllocaldb", "MyDatabase", "", "");
database.GetDBState();
database.ExecuteSingleCommand("PRINT 'Test1'");
database.ExecuteSingleCommand("RAISERROR('Test2', 0, 1, 'asd')");

//See test output windows
}
}
}
6 changes: 6 additions & 0 deletions DBMigrator/Database/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public Database(string servername, string database, string username, string pass
private void SetupConnAndLogger(string connectionString)
{
Sqlconn = new SqlConnection(connectionString);
Sqlconn.InfoMessage += Sqlconn_InfoMessage;
}

private void Sqlconn_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
_logger.LogInformation(e.Message);
}

private void CreateDBVersionTable()
Expand Down