I don´t want anything of these to be editable at all. For the Collections it seems crystal clear to use ReadOnlyCollection (though I don´t know if it´s a good way of always creating a new ReadOnlyCollection from the Collection (is it costly?)).
public static class Lookups
{
private static Collection<MyBusinessObject> businessObjects;
// [...]
public static ReadOnlyCollection<MyBusinessObjects> BusinessObjects
{
get
{
return new ReadOnlyCollection<MyBusinessObject>(businessObjects);
}
}
// [...]
}
But more important: What do I do with items inside the collections? I want this test to pass any ideas?
[TestMethod]
public void Items_Should_Not_Be_Editable()
{
var businessObject = Lookups.BusinessObjects.First();
businessObject.Id = 1337;
Assert.AreNotEqual(1337, Lookups.BusinessObjects.First().Id);
}
When using ReadonlyCollection you don't have to create a new instance every time. An alternative is to expose an IEnumerable as it is read only too. Readonlycollection offers stronger protection as can be seen here.
In your case:
As for the business objects they could have private setters or implement a read-only interface as suggested by Lars.