Esempio n. 1
0
        public void log_execute_with_answer_failure_2()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();

                Exception <DivideByZeroException> .ShouldBeThrownBy(() =>
                {
                    connection.Execute <string>(cmd, c =>
                    {
                        throw ex;
                    });
                });



                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex);
            }
        }
        public async Task log_execute_failure_2_async()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();

                Exception <DivideByZeroException> .ShouldBeThrownByAsync(async() =>
                {
                    await connection.ExecuteAsync(cmd, (c, tkn) =>
                    {
                        throw ex;
                    });
                });



                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 3
0
        public void log_execute_failure_1()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                Exception <DivideByZeroException> .ShouldBeThrownBy(() =>
                {
                    connection.Execute(c =>
                    {
                        c.CommandText = "do something";
                        throw ex;
                    });
                });



                logger.LastCommand.CommandText.ShouldBe("do something");
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 4
0
        public async Task log_execute_with_answer_failure_2_asycn()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();

                await Exception <DivideByZeroException> .ShouldBeThrownByAsync(async() =>
                {
                    await connection.ExecuteAsync <string>(cmd, async(c, tkn) =>
                    {
                        await Task.CompletedTask;
                        throw ex;
                    }
                                                           )
                    ;
                });


                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex);
            }
        }
        public async Task log_execute_with_answer_failure_1_async()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                Exception <DivideByZeroException> .ShouldBeThrownByAsync(async() =>
                {
                    connection.ExecuteAsync <string>((c, tkn) =>
                    {
                        c.CommandText = "do something";
                        throw ex;
                    });
                });



                logger.LastCommand.CommandText.ShouldBe("do something");
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 6
0
        public async Task log_execute_failure_1_async()
        {
            var ex     = new DivideByZeroException();
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                await Exception <DivideByZeroException> .ShouldBeThrownByAsync(async() =>
                {
                    await connection.ExecuteAsync(async(c, tkn) =>
                    {
                        await Task.CompletedTask;
                        c.CommandText = "do something";
                        throw ex;
                    });
                });


                logger.LastCommand.CommandText.ShouldBe("do something");
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 7
0
        public void log_execute_success_1()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                connection.Execute(c => c.CommandText = "do something");

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
        public async Task log_execute_success_1_async()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                connection.ExecuteAsync(async(c, tkn) => c.CommandText = "do something");

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 9
0
        public void log_execute_success_1()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                connection.Execute(c => c.CommandText = "do something");

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 10
0
        public void log_execute_success_2()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();
                connection.Execute(cmd, c => c.CommandText = "do something");

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
Esempio n. 11
0
        public async Task log_execute_success_1_async()
        {
            var logger = new RecordingLogger();

            using (var connection =
                       new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                await connection.ExecuteAsync(new NpgsqlCommand("select 1"));

                logger.LastCommand.CommandText.ShouldBe("select 1");
            }
        }
Esempio n. 12
0
        public void log_execute_success_with_answer_2()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();
                connection.Execute(cmd, c => "something");

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
        public async Task log_execute_success_with_answer_2_async()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();
                await connection.ExecuteAsync(cmd, async (c, tkn) => "something");

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
Esempio n. 14
0
        public async Task log_execute_success_1_async()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                await connection.ExecuteAsync(async (c, tkn) =>
                {
                    await Task.CompletedTask;
                    c.CommandText = "do something";
                });

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 15
0
        public void log_execute_success_with_answer_1()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                connection.Execute(c =>
                {
                    c.CommandText = "do something";
                    return("something");
                });

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 16
0
        public void log_execute_failure_2()
        {
            var logger = new RecordingLogger();

            using (var connection =
                       new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand("select foo from nonexistent");

                var ex = Exception <Marten.Exceptions.MartenCommandException> .ShouldBeThrownBy(() =>
                                                                                                connection.Execute(cmd));

                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex.InnerException);
            }
        }
Esempio n. 17
0
        public async Task log_execute_success_with_answer_1_async()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                await connection.Execute(async c =>
                {
                    await Task.CompletedTask;
                    c.CommandText = "do something";
                    return("something");
                });

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 18
0
        public async Task log_execute_success_2_async()
        {
            var logger = new RecordingLogger();

            using (var connection = new ManagedConnection(new ConnectionSource())
            {
                Logger = logger
            })
            {
                var cmd = new NpgsqlCommand();
                await connection.ExecuteAsync(cmd, async (c, tkn) =>
                {
                    await Task.CompletedTask;
                    c.CommandText = "do something";
                });

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
Esempio n. 19
0
        public async Task log_execute_failure_1_async()
        {
            var logger = new RecordingLogger();

            using (var connection =
                       new ManagedConnection(new ConnectionSource(), new NulloRetryPolicy())
            {
                Logger = logger
            })
            {
                var ex = await Exception <Marten.Exceptions.MartenCommandException> .ShouldBeThrownByAsync(async() =>
                {
                    await connection.ExecuteAsync(new NpgsqlCommand("select foo from nonexistent"));
                });


                logger.LastCommand.CommandText.ShouldBe("select foo from nonexistent");
                logger.LastException.ShouldBe(ex.InnerException);
            }
        }
Esempio n. 20
0
        public void log_execute_failure_1()
        {
            var ex = new DivideByZeroException();
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                Exception<DivideByZeroException>.ShouldBeThrownBy(() =>
                {
                    connection.Execute(c =>
                    {
                        c.CommandText = "do something";
                        throw ex;
                    });
                });



                logger.LastCommand.CommandText.ShouldBe("do something");
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 21
0
        public async Task log_execute_with_answer_failure_1_async()
        {
            var ex = new DivideByZeroException();
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                await Exception<DivideByZeroException>.ShouldBeThrownByAsync(async () =>
                {
                    await connection.ExecuteAsync<string>(async (c, tkn) =>
                    {
                        await Task.CompletedTask;
                        c.CommandText = "do something";
                        throw ex;
                    });
                });



                logger.LastCommand.CommandText.ShouldBe("do something");
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 22
0
        public async Task log_execute_with_answer_failure_2_asycn()
        {
            var ex = new DivideByZeroException();
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                var cmd = new NpgsqlCommand();

                await Exception<DivideByZeroException>.ShouldBeThrownByAsync(async () =>
                {
                    await connection.ExecuteAsync<string>(cmd, async (c, tkn) =>
                    {
                        await Task.CompletedTask;
                        throw ex;
                    }
                )
                    ;
                });



                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 23
0
        public async Task log_execute_success_with_answer_1_async()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                await connection.Execute(async c =>
                {
                    await Task.CompletedTask;
                    c.CommandText = "do something";
                    return "something";
                });

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 24
0
        public void log_execute_success_2()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                var cmd = new NpgsqlCommand();
                connection.Execute(cmd, c => c.CommandText = "do something");

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
Esempio n. 25
0
        public async Task log_execute_success_1_async()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                connection.ExecuteAsync(async (c, tkn) => c.CommandText = "do something");

                logger.LastCommand.CommandText.ShouldBe("do something");
            }
        }
Esempio n. 26
0
        public void log_execute_with_answer_failure_2()
        {
            var ex = new DivideByZeroException();
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                var cmd = new NpgsqlCommand();

                Exception<DivideByZeroException>.ShouldBeThrownBy(() =>
                {
                    connection.Execute<string>(cmd, c =>
                    {
                        throw ex;
                    });
                });



                logger.LastCommand.ShouldBe(cmd);
                logger.LastException.ShouldBe(ex);
            }
        }
Esempio n. 27
0
        public async Task log_execute_success_with_answer_2_async()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                var cmd = new NpgsqlCommand();
                await connection.ExecuteAsync(cmd, async (c, tkn) =>
                {
                    await Task.CompletedTask;
                    return "something";
                });

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }
Esempio n. 28
0
        public async Task log_execute_success_2_async()
        {
            var logger = new RecordingLogger();
            using (var connection = new ManagedConnection(new ConnectionSource()) {Logger = logger})
            {
                var cmd = new NpgsqlCommand();
                await connection.ExecuteAsync(cmd, async (c, tkn) => c.CommandText = "do something");

                logger.LastCommand.ShouldBeSameAs(cmd);
            }
        }