I'm setting up data for testing by creating a few dozen static objects of a custom type. I want to have a list of these objects so that I can make dynamic assertions during testing. Here's the class and the objects:
public class Publication
{
public string Name { get; set; }
public string DropdownText { get; set; }
public string DropdownValue { get; set; }
public string BaseURL { get; set; }
public static Publication MotocrossWeekly = new Publication {
Name = "Motocross Weekly",
DropdownText = "Motocross Weekly",
DropdownValue = "18",
};
public static Publication ExtremeWelding = new Publication {
Name = "Extreme Welding",
DropdownText = "Extreme Welding",
DropdownValue = "6",
};
public static Publication HackersGuide = new Publication {
Name = "Hacker's Guide to Security",
DropdownText = "Hacker's Guide",
DropdownValue = "36",
};
...
public static IList<Publication> Publications = ???;
The goal is to have a static list of Publications that would contain all of the Publication objects within the Publication class. This is to avoid having to manually write out each object in the list and editing the list every time one is added or removed from the system.
I think this can be accomplished with reflection, but I can't find specifics for what I'm trying to do.
Aucun commentaire:
Enregistrer un commentaire