Exemple #1
0
        public when_reading_500_rows()
        {
            TestingUtils.PostgresCommand("DROP TABLE IF EXISTS skinny_testing");
            TestingUtils.PostgresCommand("CREATE TABLE skinny_testing (firstname varchar(100), lastname varchar(100), address varchar(500), age int)");

            var sql = new StringBuilder();

            for (var i = 0; i < 500; i++)
            {
                sql.Append($"INSERT INTO skinny_testing (firstname, lastname, address, age) VALUES ('jane', 'doe', '{i} Walnut Street', {i});");
            }

            TestingUtils.PostgresCommand(sql.ToString());

            var connection = new Connection(Settings.ConnectionString);

            var query = "SELECT * FROM skinny_testing";

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            read = connection.Query <SkinnyTestingDatabaseRecord>(query, new Dictionary <string, object>());

            stopwatch.Stop();

            mappingTimeInMilliseconds = stopwatch.ElapsedMilliseconds;
        }
Exemple #2
0
        public when_mapping_results_to_field()
        {
            TestingUtils.PostgresCommand("DROP TABLE IF EXISTS skinny_testing");
            TestingUtils.PostgresCommand("CREATE TABLE skinny_testing (title varchar(100))");
            TestingUtils.PostgresCommand("INSERT INTO skinny_testing (title) VALUES ('some testing')");
            TestingUtils.PostgresCommand("INSERT INTO skinny_testing (title) VALUES ('other testing')");

            var connection = new Connection(Settings.ConnectionString);

            var query = "SELECT * FROM skinny_testing";

            actual = connection.Query <SkinnyTestingDatabaseRecord>(query, new Dictionary <string, object>());
        }
Exemple #3
0
        public when_querying_with_more_columns_than_what_is_being_mapped()
        {
            TestingUtils.PostgresCommand("DROP TABLE IF EXISTS skinny_testing");
            TestingUtils.PostgresCommand("CREATE TABLE skinny_testing (title varchar(100), not_being_mapped varchar(200))");
            TestingUtils.PostgresCommand("INSERT INTO skinny_testing (title) VALUES ('some testing')");

            var connection = new Connection(Settings.ConnectionString);

            var query = "SELECT * FROM skinny_testing where title = @title";

            var parameters = new Dictionary <string, object>()
            {
                { "title", "some testing" }
            };

            actual = connection.Query <SkinnyTestingDatabaseRecord>(query, parameters);
        }