Example #1
0
 protected override void InsertMultipleTest(int count)
 {
   using (var statelessSession = factory.OpenStatelessSession())
   using (var transaction = statelessSession.BeginTransaction()) {
     for (int i = 0; i < count; i++) {
       var s = new Simplest(i, i);
       statelessSession.Insert(s);
     }
     transaction.Commit();
   }
   InstanceCount = count;
 }
Example #2
0
 protected override void InsertSingleTest(int count)
 {
     using (var insertSession = _factory.OpenSession())
     using (var transaction = insertSession.BeginTransaction())
     {
         for (int i = 0; i < count; i++)
         {
             var s = new Simplest(i, i);
             insertSession.Save(s);
             insertSession.Flush();
             insertSession.Clear();
         }
         transaction.Commit();
     }
     InstanceCount = count;
 }
Example #3
0
    protected override void NativeQueryTest(int count)
    {
      using(var transaction = con.BeginTransaction()) {
        var cmd = con.CreateCommand();
        cmd.Transaction = transaction;
        cmd.CommandText = "SELECT [Simplests].[Id], [Simplests].[Value] " + 
          "FROM [dbo].[Simplests] WHERE [Simplests].[id] = @pId";
        cmd.Parameters.Add(new SqlParameter("@pId", SqlDbType.BigInt));
        SqlDataReader dr;

        for (int i = 0; i < count; i++) {
          cmd.Parameters["@pId"].SqlValue = i % InstanceCount;
          dr = cmd.ExecuteReader();

          var s = new Simplest();
          while (dr.Read()) {
            if (!dr.IsDBNull(0))
              s.Id = dr.GetInt64(0);
            if (!dr.IsDBNull(1))
              s.Value = dr.GetInt64(1);
          }
          dr.Close();
        }
        transaction.Commit();
      }
    }
Example #4
0
    protected override void NativeMaterializeTest(int count)
    {
      long sum = 0;
      int i = 0;
      using(var transaction = con.BeginTransaction()) {
        while (i < count) {
          SqlCommand cmd = con.CreateCommand();
          cmd.Transaction = transaction;
          cmd.CommandText = "SELECT [Simplests].[Id], [Simplests].[Value] " +
            "FROM [dbo].[Simplests]";
          cmd.Prepare();

          SqlDataReader dr = cmd.ExecuteReader();
          while (dr.Read()) {
            var s = new Simplest();
            if (!dr.IsDBNull(0))
              s.Id = dr.GetInt64(0);
            if (!dr.IsDBNull(1))
              s.Value = dr.GetInt64(1);
            sum += s.Id;
            if (++i >= count)
              break;
          }
          dr.Close();
        }
        transaction.Commit();
      }
      Assert.AreEqual((long)count * (count - 1) / 2, sum);
    }
Example #5
0
    protected override void FetchTest(int count)
    {
      long sum = (long) count * (count - 1) / 2;
      using(var transaction = con.BeginTransaction()) {
        var cmd = con.CreateCommand();
        cmd.Transaction = transaction;
        cmd.CommandText = "SELECT [Simplests].[Id], [Simplests].[Value] " + 
          "FROM [dbo].[Simplests] WHERE [Simplests].[Id] = @pId";
        cmd.Parameters.Add(new SqlParameter("@pId", SqlDbType.BigInt));
        cmd.Prepare();
        SqlDataReader dr;

        for (int i = 0; i < count; i++) {
          cmd.Parameters["@pId"].SqlValue = i % InstanceCount;
          dr = cmd.ExecuteReader();

          var s = new Simplest();
          while (dr.Read()) {
            if (!dr.IsDBNull(0))
              s.Id = dr.GetInt64(0);
            if (!dr.IsDBNull(1))
              s.Value = dr.GetInt64(1);
          }
          sum -= s.Id;
          dr.Close();
        }
        transaction.Commit();
      }
      if (count <= InstanceCount)
        Assert.AreEqual(0, sum);
    }