예제 #1
0
        public void Notice()
        {
            // Make sure messages are in English
            ExecuteNonQuery(@"SET lc_messages='English_United States.1252'");
            ExecuteNonQuery(@"
                 CREATE OR REPLACE FUNCTION emit_notice() RETURNS VOID AS
                    'BEGIN RAISE NOTICE ''testnotice''; END;'
                 LANGUAGE 'plpgsql';
            ");

            NpgsqlNotice       notice = null;
            NoticeEventHandler action = (sender, args) => notice = args.Notice;

            Conn.Notice += action;
            try
            {
                ExecuteNonQuery("SELECT emit_notice()::TEXT");  // See docs for CreateSleepCommand
                Assert.That(notice, Is.Not.Null, "No notice was emitted");
                Assert.That(notice.MessageText, Is.EqualTo("testnotice"));
                Assert.That(notice.Severity, Is.EqualTo("NOTICE"));
            }
            finally
            {
                Conn.Notice -= action;
            }
        }
예제 #2
0
        public void Notice()
        {
            ExecuteNonQuery(@"
                 CREATE OR REPLACE FUNCTION emit_notice() RETURNS VOID AS
                    'BEGIN RAISE NOTICE ''testnotice''; END;'
                 LANGUAGE 'plpgsql';
            ");

            NpgsqlNotice       notice = null;
            NoticeEventHandler action = (sender, args) => notice = args.Notice;

            Conn.Notice += action;
            try
            {
                ExecuteNonQuery("SELECT emit_notice()");
                Assert.That(notice, Is.Not.Null, "No notice was emitted");
                Assert.That(notice.MessageText, Is.EqualTo("testnotice"));
                Assert.That(notice.Severity, Is.EqualTo(ErrorSeverity.Notice));
            }
            finally
            {
                Conn.Notice -= action;
            }
        }