🐛 fix: RecipeCollection is now correctly enumerable

pull/24/head
Alexandre Agostinho 2 years ago
parent e68a9ac48d
commit 50f2cb43a4

@ -29,7 +29,7 @@ Console.WriteLine("test overload of [] operator:");
try try
{ {
rc[2].DisplayId(); rc[2].DisplayId();
rc.GetById(14).DisplayId(); rc.GetById(110).DisplayId();
} }
catch (ArgumentNullException) catch (ArgumentNullException)
{ {
@ -51,5 +51,5 @@ RecipeCollection rc2 = new RecipeCollection(
Console.WriteLine("test of Enumerable property:"); Console.WriteLine("test of Enumerable property:");
foreach (Recipe r in rc2) foreach (Recipe r in rc2)
{ {
r.DisplayId(); Console.Write(" - "); r.DisplayId();
} }

@ -39,7 +39,7 @@ namespace Model
public RecipeCollection(params Recipe[] recipes) public RecipeCollection(params Recipe[] recipes)
: base(ComputeId()) : base(ComputeId())
{ {
_recipes.CopyTo(recipes, 0); _recipes = new List<Recipe>(recipes);
} }
#endregion #endregion
@ -116,7 +116,7 @@ namespace Model
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return _recipes.GetEnumerator(); return this.GetEnumerator();
} }
#endregion #endregion

Loading…
Cancel
Save