Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Data driven unit tests: how does the test framework determine the datarow-order?

Data driven unit tests: how does the test framework determine the datarow-order?

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studioregexquestion
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erik
    wrote on last edited by
    #1

    Hi, I am currently writing some unit tests for my C# application, so I made an Access database with various datasets containing multiple test values. The first column contains an ID which is only a number starting at 1 in the first row, and is increased every next line. This is my primary key. I implement this test database in my Test class like this: [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\TestData.mdb", "CValues", DataAccessMethod.Sequential), DeploymentItem("Tests\\TestData.mdb"), TestMethod()] This works fine, however when I display the test results in VS 2010, the "Data Row" does not match the order in my database. Currently, my Database has about 30 entrys, and the datarow-output in VS 2010 begins with row 8 from my database, going to the end, and the first 7 rows in my database are displayed as the last datarows in VS 2010. I would really appreciate if I had the same datarow order in access and VS2010 so I can easily compare both of them. How can this be achieved?

    L 1 Reply Last reply
    0
    • E Erik

      Hi, I am currently writing some unit tests for my C# application, so I made an Access database with various datasets containing multiple test values. The first column contains an ID which is only a number starting at 1 in the first row, and is increased every next line. This is my primary key. I implement this test database in my Test class like this: [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\TestData.mdb", "CValues", DataAccessMethod.Sequential), DeploymentItem("Tests\\TestData.mdb"), TestMethod()] This works fine, however when I display the test results in VS 2010, the "Data Row" does not match the order in my database. Currently, my Database has about 30 entrys, and the datarow-output in VS 2010 begins with row 8 from my database, going to the end, and the first 7 rows in my database are displayed as the last datarows in VS 2010. I would really appreciate if I had the same datarow order in access and VS2010 so I can easily compare both of them. How can this be achieved?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, AFAIK database query results are ordered as much as you request them to be in a specific order; without an ORDER BY clause, they are in random order. If you don't want to add an ORDER BY clause, the best you can do is sort the results yourself before comparing them with your expected set of results. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      E 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, AFAIK database query results are ordered as much as you request them to be in a specific order; without an ORDER BY clause, they are in random order. If you don't want to add an ORDER BY clause, the best you can do is sort the results yourself before comparing them with your expected set of results. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        E Offline
        E Offline
        Erik
        wrote on last edited by
        #3

        Thanks, this worked great, I simply created a Query called ValuesSortedQuery which I use in my DataContext, the query is really simple and looks something like this: SELECT * FROM Values ORDER BY Values.ID; Works just fine :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups