Ejemplo n.º 1
0
        public async Task Blah()
        {
            Marker("Started");

            using (var sqlServer = new SqlServerViaDockerSlow("sqlserver-prepped"))
            {
                await sqlServer.Start();

                using (var db = new SqlConnection($"Server={sqlServer.Host},{sqlServer.Port};User Id=sa;Password=Wibble123!"))
                {
                    await db.OpenAsync();

                    await db.ExecuteAsync(@"
                        INSERT INTO Camels
                        VALUES 
                            ('Clarence', 12),
                            ('Cassandra', 10),
                            ('Cuthbert', 8)
                      ");

                    var camels = await db.QueryAsync("SELECT * FROM Camels");

                    Assert.That(camels.Count(), Is.EqualTo(3));
                }
            }
        }
Ejemplo n.º 2
0
        public async Task Normal()
        {
            Marker("Starting");

            using (var sqlServer = new SqlServerViaDockerSlow("sqlservr-camels"))
            {
                await sqlServer.Start();

                Marker("Started");

                using (var db = new SqlConnection($"Server={sqlServer.Host},{sqlServer.Port};Database=CamelsRUs;User Id=sa;Password=Wibble123!"))
                {
                    await db.OpenAsync();

                    Marker("Opened");

                    var ranchId = await db.CreateRanch(name : "Jason's Camel Ranch");

                    var camelId1 = await db.CreateCamel(name : "Claude", species : "Dromedary", age : 7);

                    await db.PlaceCamel(ranchId, camelId1);

                    var camelId2 = await db.CreateCamel(name : "Claudette", species : "Persian", age : 14);

                    await db.PlaceCamel(ranchId, camelId2);


                    var camels = await db.QueryAsync("SELECT * FROM Camels WHERE Species IN ('Bactrian', 'Wild Bactrian', 'Dromedary')");

                    Assert.That(camels.Count(), Is.EqualTo(1));
                }

                Marker("Finished");
            }
        }
Ejemplo n.º 3
0
        public async Task Available_AfterStart()
        {
            using (var sql = new SqlServerViaDockerSlow("sqlservr-tracking"))
            {
                await sql.Start(CancellationToken.None);

                var connectionString =
                    $"Server={sql.ServerUri.Host},{sql.ServerUri.Port};Database=electio_tracking;User Id=sa;Password=Wibble123!;Encrypt=False;Connection Timeout=30;MultipleActiveResultSets=True";

                using (var connection = new SqlConnection(connectionString))
                {
                    await connection.OpenAsync();
                }
            }
        }
Ejemplo n.º 4
0
        public async Task Blah()
        {
            Marker("Start");

            using (var sqlServer = new SqlServerViaDockerSlow("sqlserver-simple"))
            {
                await sqlServer.Start();

                Marker("SqlServer ready");

                using (var db = new SqlConnection($"Server={sqlServer.Host},{sqlServer.Port};User Id=sa;Password=Wibble123!"))
                {
                    await db.OpenAsync();

                    Marker("Connected");

                    await db.ExecuteAsync(@"
                        CREATE DATABASE Demo;

                        CREATE TABLE Camels (
                            Name nvarchar(50),
                            Age int
                        );

                        INSERT INTO Camels
                        VALUES 
                            ('Clarence', 12),
                            ('Cassandra', 10),
                            ('Cuthbert', 8)
                      ");

                    Marker("Created");

                    var camels = await db.QueryAsync("SELECT * FROM Camels");

                    Assert.That(camels.Count(), Is.EqualTo(3));
                }

                Marker("Done!");
            }
        }