<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using SQLDatabase.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace SQLDatabase.Tests
{
    [TestClass]
    public class HelperClass
    {
        [TestClass]
        public class CreateConnectionMethod
        {
            [TestMethod]
            public void ReturnsAnOpenConnection()
            {
                using (var connection = Helper.CreateConnection())
                {
                    Assert.IsTrue(connection.State == ConnectionState.Open);
                }
            }

            [TestMethod]
            public async void ReturnsConnectionThatCanSelectFromLocations()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection))
                    await transaction.GetAsync<int>("select count(*) from locations");
            }

            [TestMethod]
            public async void ReturnsConnectionThatCanSelectFromIdentifiers()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection))
                    await transaction.GetAsync<int>("select count(*) from identifiers");
            }

            [TestMethod]
            public async void ReturnsConnectionThatCanInsertIdentifier()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection)) // Is automatically rolled back
                {
                    var numAffected = await transaction.ExecuteAsync("insert into identifiers(hex) values (0x0000)");
                    Assert.AreEqual(1, numAffected);
                }
            }

            [TestMethod]
            public async void ReturnsConnectionThatCanInsertLocation()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection)) // Is automatically rolled back
                {
                    var id = transaction.GetAsync<int>("insert into identifiers(hex) values (0x0000); select cast(SCOPE_IDENTITY() as int) as id");
                    var numAffected = await transaction.ExecuteAsync("insert into locations(id, latitude, longitude) values (@id, 0, 0)", new SqlParameter("@id", id));
                    Assert.AreEqual(1, numAffected);
                }
            }
        }
    }
}<commit_msg>Forgot about "async void" being bad for tests<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using SQLDatabase.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;

namespace SQLDatabase.Tests
{
    [TestClass]
    public class HelperClass
    {
        [TestClass]
        public class CreateConnectionMethod
        {
            [TestMethod]
            public void ReturnsAnOpenConnection()
            {
                using (var connection = Helper.CreateConnection())
                {
                    Assert.IsTrue(connection.State == ConnectionState.Open);
                }
            }

            [TestMethod]
            public async Task ReturnsConnectionThatCanSelectFromLocations()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection))
                    await transaction.GetAsync<int>("select count(*) from locations");
            }

            [TestMethod]
            public async Task ReturnsConnectionThatCanSelectFromIdentifiers()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection))
                    await transaction.GetAsync<int>("select count(*) from identifiers");
            }

            [TestMethod]
            public async Task ReturnsConnectionThatCanInsertIdentifier()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection)) // Is automatically rolled back
                {
                    var numAffected = await transaction.ExecuteAsync("insert into identifiers(hex) values (0x0000)");
                    Assert.AreEqual(1, numAffected);
                }
            }

            [TestMethod]
            public async Task ReturnsConnectionThatCanInsertLocation()
            {
                using (var connection = Helper.CreateConnection())
                using (var transaction = new Transaction(connection)) // Is automatically rolled back
                {
                    var id = transaction.GetAsync<int>("insert into identifiers(hex) values (0x0000); select cast(SCOPE_IDENTITY() as int) as id");
                    var numAffected = await transaction.ExecuteAsync("insert into locations(id, latitude, longitude) values (@id, 0, 0)", new SqlParameter("@id", id));
                    Assert.AreEqual(1, numAffected);
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08244478293983244, 'fraction_numerical': 0.005331302361005331, 'mean_word_length': 1.8767798466593648, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5877662', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1134, 'n_words': 305}