public void SqlTrannectionShouldExecuteSqlOnItsTarget()
 {
     using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
     {
         testSubject.ExecuteScalar <long>("select 1;").Result.Should().Be(1);
     }
 }
 public void SqlTrannectionShouldExecuteNonQuery()
 {
     using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
     {
         testSubject.ExecuteNonQuery(string.Format(CreateJunkTable, _tableUid))
         .Wait();
         testSubject.ExecuteScalar <long>(string.Format(CountJunkTables, _tableUid))
         .Result.Should().Be(1);
     }
 }
 public void SqlTrannectionShouldCloseItsConnectionWhenItIsDisposed()
 {
     using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
     {
         testSubject.IsOpen.Should().BeFalse();
         testSubject.ExecuteScalar <long>("select 1;").Result.Should().Be(1);
         testSubject.IsOpen.Should().BeTrue();
         testSubject.Dispose();
         testSubject.IsOpen.Should().BeFalse();
     }
 }
 public void SqlTrannectionShouldRollbackUnlessInstructedOtherwise()
 {
     using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
     {
         MakeJunkTable(testSubject);
         NumJunkTablesShouldBe(testSubject, 1);
     }
     using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
     {
         NumJunkTablesShouldBe(testSubject, 0);
     }
 }
 public void SqlTrannectionShouldBeCommittable()
 {
     try
     {
         using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
         {
             MakeJunkTable(testSubject);
             NumJunkTablesShouldBe(testSubject, 1);
             testSubject.Commit();
         }
         using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
         {
             NumJunkTablesShouldBe(testSubject, 1);
         }
     }
     finally
     {
         using (var testSubject = new DbTranection(DbToUse, ConnectionStringToUse))
         {
             RemoveJunkTable(testSubject);
             testSubject.Commit();
         }
     }
 }
 private void RemoveJunkTable(DbTranection testSubject)
 {
     testSubject.ExecuteNonQuery(string.Format(DropJunkTable, _tableUid))
     .Wait();
 }
 private void NumJunkTablesShouldBe(DbTranection testSubject, int expected)
 {
     testSubject.ExecuteScalar <long>(string.Format(CountJunkTables, _tableUid))
     .Result.Should().Be(expected);
 }
 private void MakeJunkTable(DbTranection testSubject)
 {
     testSubject.ExecuteNonQuery(string.Format(CreateJunkTable, _tableUid))
     .Wait();
 }