public void SortPizzaWhenAdded(Pizza[] pizzas) { foreach (var pizza in pizzas) { _sut.AddPizza(pizza); } Assert.True(PizzasAreOrderedByIngredientsCountAscending(_sut.PizzaLine)); //-- local functions bool PizzasAreOrderedByIngredientsCountAscending(Pizza pizza) { if (pizza.NextPizza is null) { return(true); } if (pizza.IngredientsCount <= pizza.NextPizza.IngredientsCount) { return(PizzasAreOrderedByIngredientsCountAscending(pizza.NextPizza)); } else { return(false); } } }