Beispiel #1
0
        public void TestErrorLogging(IConnectionManager conn)
        {
            //Arrange
            CreateLogTableTask.Create(conn, "test_log");
            ControlFlow.AddLoggingDatabaseToConfig(conn, NLog.LogLevel.Trace, "test_log");
            //Act
            LogTask.Error(conn, "Error!");
            LogTask.Warn(conn, "Warn!");
            LogTask.Info(conn, "Info!");
            LogTask.Debug(conn, "Debug!");
            LogTask.Trace(conn, "Trace!");
            LogTask.Fatal(conn, "Fatal!");
            //Assert
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Error!' AND {conn.QB}level{conn.QE} = 'Error' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Warn!' AND {conn.QB}level{conn.QE} = 'Warn' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Info!' AND {conn.QB}level{conn.QE} = 'Info' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Debug!' AND {conn.QB}level{conn.QE} = 'Debug' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Trace!' AND {conn.QB}level{conn.QE} = 'Trace' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Fatal!' AND {conn.QB}level{conn.QE} = 'Fatal' AND {conn.QB}task_action{conn.QE} = 'LOG'"));

            //Cleanup
            DropTableTask.Drop(conn, ControlFlow.LogTable);
        }