Skip to content

Instantly share code, notes, and snippets.

@glauco
Created July 18, 2012 14:44
Show Gist options
  • Save glauco/3136604 to your computer and use it in GitHub Desktop.
Save glauco/3136604 to your computer and use it in GitHub Desktop.
BaseTest
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace MT.SmsNavigationFactory.Tests
{
public abstract class BaseTest
{
protected void Delete(string sql)
{
using (var connection = new SqlConnection("Data Source=.;Initial Catalog=SmsNavigationFactory;Integrated Security=True;MultipleActiveResultSets=True"))
{
connection.Open();
using (var command = new SqlCommand(sql, connection))
{
command.ExecuteNonQuery();
}
connection.Close();
}
}
protected T Create<T>(string sql)
{
T id;
using (var connection = new SqlConnection("Data Source=.;Initial Catalog=SmsNavigationFactory;Integrated Security=True;MultipleActiveResultSets=True"))
{
connection.Open();
using (SqlCommand command = new SqlCommand(sql, connection))
{
var result = command.ExecuteScalar();
id = (T)result;
}
connection.Close();
}
return id;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment