/Rhino.Etl.Tests/LoadTest/LoadTestFixture.cs

http://github.com/ayende/rhino-etl · C# · 79 lines · 63 code · 12 blank · 4 comment · 2 complexity · f5591c88b175fcd3b4ae18902f6cdb6d MD5 · raw file

  1. using Rhino.Etl.Core.Infrastructure;
  2. namespace Rhino.Etl.Tests.LoadTest
  3. {
  4. using System.Data;
  5. using Core;
  6. using Xunit;
  7. using Rhino.Etl.Core.Operations;
  8. /// <summary>
  9. /// This fixture is here to verify that we can handle large amount of data
  10. /// without consuming too much memory or crashing
  11. /// </summary>
  12. public class LoadTestFixture : BaseUserToPeopleTest
  13. {
  14. private const int expectedCount = 5000;
  15. private int currentUserCount;
  16. public LoadTestFixture()
  17. {
  18. currentUserCount = GetUserCount("1 = 1");
  19. using (PushDataToDatabase push = new PushDataToDatabase(expectedCount))
  20. push.Execute();
  21. }
  22. public void AssertUpdatedAllRows()
  23. {
  24. Assert.Equal(expectedCount + currentUserCount, GetUserCount("testMsg is not null"));
  25. }
  26. private static int GetUserCount(string where)
  27. {
  28. return Use.Transaction<int>("test", delegate(IDbCommand command)
  29. {
  30. command.CommandText = "select count(*) from users where " + where;
  31. return (int)command.ExecuteScalar();
  32. });
  33. }
  34. [Fact]
  35. public void CanUpdateAllUsersToUpperCase()
  36. {
  37. using (UpperCaseUserNames update = new UpperCaseUserNames())
  38. {
  39. update.RegisterLast(new UpdateUserNames());
  40. update.Execute();
  41. }
  42. AssertUpdatedAllRows();
  43. }
  44. [Fact]
  45. public void CanBatchUpdateAllUsersToUpperCase()
  46. {
  47. using (UpperCaseUserNames update = new UpperCaseUserNames())
  48. {
  49. update.RegisterLast(new BatchUpdateUserNames());
  50. update.Execute();
  51. }
  52. AssertUpdatedAllRows();
  53. }
  54. [Fact]
  55. public void BulkInsertUpdatedRows()
  56. {
  57. if(expectedCount != GetUserCount("1 = 1"))
  58. return;//ignoring test
  59. using (UpperCaseUserNames update = new UpperCaseUserNames())
  60. {
  61. update.RegisterLast(new BulkInsertUsers());
  62. update.Execute();
  63. }
  64. AssertUpdatedAllRows();
  65. }
  66. }
  67. }