For unit testing, I usually do not upload data in advance - each test is designed to work with a data source that may or may not contain existing records, so each test records all the records necessary to complete the test.
When choosing values ββto send to the database, I use the GUID (or other random values) when possible, as this ensures that the values ββin the database are unique (for example, if you create someone named "Mr XY", itβs useful to know that the search "X" should return only 1 result and that there is no chance that you accidentally encountered someone else in the database whose last name would be Y)
Often when testing modules, I test methods that modify data along with methods that read data, and therefore my unit tests use the same API (the one that is being tested) to write to the database. (Well, if each unit test covers a certain area of ββfunctionality, but this is not absolutely necessary)
If the API under test does not have methods for writing to the database, I write my own set of auxiliary functions - the exact structure will depend on the data source, but as an example I often use LINQ to SQL.
source share