コード例 #1
0
        public async Task Normal()
        {
            Marker("Starting");

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

                Marker("Started");

                using (var db = new SqlConnection($"Server=localhost,1433;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");
            }
        }
コード例 #2
0
        public async Task Blah()
        {
            Marker("Started");

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

                Marker("SqlServer ready");

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

                    Marker("Connected");

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

                    Marker("Created");

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

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

                Marker("Done!");
            }
        }
コード例 #3
0
ファイル: Demo.cs プロジェクト: jasonholloway/talks
        public async Task Blah()
        {
            Marker("Start");

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

                Marker("SqlServer ready");

                using (var db = new SqlConnection($"Server=localhost,1433;User Id=sa;Password=Wibble123!"))
                {
                    await db.OpenAsync();

                    Marker("Connected");

                    await db.ExecuteAsync(@"
                        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!");
            }
        }