「幸せな」テストシナリオでデータベースから返された実際のデータを返すだけであっても、ルックアップテーブルをモックします。
ただし、データがデータベースから削除された場合や、データが返されない場合など、エッジ ケースを柔軟にテストできます。
例えば
// Happy tests:
Mock.Setup for GetLookupData() => return FetchRealDataHere();
Assert.AreEqual(3, Mock.Object.CountOfSizes()); // Ensure that Small, Medium and Large
... Do Good scenario unit Tests here
// Test Edge cases / destructive tests
Mock.Setup for GetLookupData() => return new Collection() [{ Small, 1}] [{ Medium 2}] - // But omit large
... Exception case Unit tests here, e.g. Try and Insert a Large product here.
// Test empty collection
Mock.Setup for GetLookupData() => return new Collection() [Empty]
// Assert that "NoItemsFoundException" was thrown by your logic here
// Handle empty collection
Mock.Setup for GetLookupData() => return new Collection() [Empty]
編集以下の更新されたコメントの疑似モックセットアップ/ユニットテストコードを更新しました。