Example #1
0
        public async Task Execute_query_no_parameters_success()
        {
            using (var connection = new PeregrineConnection {
                ConnectionString = ConnectionString
            })
            {
                await connection.OpenAsync();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "select id, message from fortune";

                    await command.PrepareAsync();

                    var fortunes = new List <Fortune>();

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            fortunes.Add(
                                new Fortune
                            {
                                Id      = reader.GetInt32(0),
                                Message = reader.GetString(1)
                            });
                        }
                    }

                    Assert.Equal(12, fortunes.Count);
                }
            }
        }
Example #2
0
        public async Task Open_success()
        {
            using (var connection = new PeregrineConnection {
                ConnectionString = ConnectionString
            })
            {
                Assert.NotEqual(ConnectionState.Open, connection.State);

                await connection.OpenAsync();

                Assert.Equal(ConnectionState.Open, connection.State);
            }
        }