Skip to content

Instantly share code, notes, and snippets.

@achvaicer
Created March 28, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achvaicer/9838237 to your computer and use it in GitHub Desktop.
Save achvaicer/9838237 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using SharpTestsEx;
using Vinci.Framework.DataBase;
namespace TestDapper
{
[TestFixture]
public class Bla
{
private const string ConnectionString = "VinciDB";
private const int Total = 100000;
private static readonly string[] Isins = new []
{
"US0594603039",
"US05967A1079",
"US29081M1027",
"US3626073015",
"US3737371050",
"US38045R1077",
"US4655621062",
"US71654V1017",
"US87484D1037",
"US88706P1066",
"US91912E1055",
"US91912E2046"
};
private static readonly int[] Ids = new [] { 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644 };
[Test]
public void ParallelPorIsin()
{
Parallel.For(0, Total, (i) =>
{
using (var db = DataBaseFactory.GetDataBase(ConnectionString))
db.Execute<Ativo>("up_GetAtivoByISIN", new {ISINCode = Isins[i%12]})
.Count()
.Should()
.Be.GreaterThanOrEqualTo(1);
});
}
[Test]
public void ParallelPorId()
{
Parallel.For(0, Total, (i) =>
{
var ativoID = Ids[i%45];
using (var db = DataBaseFactory.GetDataBase(ConnectionString))
db.ExecuteSingle<Ativo>("up_GetAtivoByID", new Dictionary<string, object>() { { "AtivoID", ativoID } }).AtivoID.Should().Be(ativoID);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment