public void TestErrorSuccess() { // Arrange var guid = Guid.NewGuid(); var logger = new OneHydraLogger("MyTestLogger"); var helper = new ConfigManagerHelper(); var connString = helper.GetConnectionString("OneHydraLog"); var query = string.Format(@" SELECT [Id], [Date], [Thread], [Level], [Logger], [Message], [Exception], [MachineName] FROM [dbo].[OneSearchLog] WHERE Message LIKE {0}", guid.ForSql()); // Act logger.Error(guid.ToString(), new Exception("Test exception")); // Clean up dynamic logRow; using (var conn = new SqlConnection(connString)) { logRow = conn.GetObject(query, r =>new { Id = r.GetInt32(0), Date = r.GetDateTime(1), Thread = r.GetString(2), Level = r.GetString(3), Logger = r.GetString(4), Message = r.GetString(5), Exception = r.GetString(6), MachineName = r.GetString(7) }); conn.ExecuteNonQuery(string.Format("DELETE FROM [dbo].[OneSearchLog] WHERE Message LIKE {0} ", guid.ForSql())); } // Assert Assert.IsNotNull(logRow); Assert.AreEqual(guid.ToString(), logRow.Message); Assert.AreEqual("Test exception\r\n", logRow.Exception); Assert.AreEqual(Environment.MachineName, logRow.MachineName); Assert.AreEqual("ERROR", logRow.Level); Assert.AreEqual("MyTestLogger", logRow.Logger); }
public void TestGetConnectionString() { var helper = new ConfigManagerHelper(); var connString = helper.GetConnectionString("OneHydra"); Assert.AreEqual("Server=onehydra-dev.database.windows.net;initial catalog=OneSearch_Dev;User ID=Greenlight@onehydra-dev;Password=1poldo1.;Trusted_Connection=False;Persist Security Info=True;", connString); }
public void TestGetAppSetting() { var helper = new ConfigManagerHelper(); var connString = helper.GetAppSetting("DataConnectionString"); Assert.AreEqual("AccountName=onehydratest;AccountKey=jh50v102CF9DMU71vNoel0O0csTmsXfhasPWUL/tUCZ7icu0z2QMPV0rLOXN+9dTmgQHyFzOUFOZdY+Cf01sTA==;DefaultEndpointsProtocol=https", connString); }