Essentially, there are no constructors in the API. Instead, Collection.AddNew() is used as a factory method. The Collection class is generic and there is to my knowledge no way of checking what type of object (package, element, attribute, etc) it contains in runtime -- you simply have to know which is which.
The contents of the repository are accessed recursively. A newly created repository contains one single root-level package (default name "Model"), which you can retrieve from the Repository.Models collection.
The method I suggested requires an element Collection from a non-root package. Root level packages can only contain packages ("view" packages in the project browser), but those packages in turn can contain elements and diagrams as well as further child packages. Thus, trying AddNew() on the Elements collection of a root-level package will cause an error.
So it's a question of how much you want to create within the context of the test method. You could go as far as creating the repository itself (Repository.CreateModel()), but that can take several seconds which is probably not acceptable in a unit test so you'll most likely want to do that as part of your test initialisation.
Similarly, you could create the view-level package inside the test method. This doesn't take as anywhere near as much time but for convenience I'd push that to the initialisation as well.
So something along the following lines should do it.
public Package InitTestRepository(Repository repository, string eapFileName)
{
repository.CreateModel(cmEAPFromBase, eapFileName, 0);
Package rootPackage = repository.Models.GetAt(0);
return rootPackage.Packages.AddNew("Test View", "Package");
}During initialisation, store the result in a member or global variable, then simply pass thatVariable.Elements to test methods which create elements, thatVariable.Packages to methods which create packages, etc.