I'm currently at the point where I want to write a test for my ASP.net Core MVC project.
The problem is that I currently put this code into my view, which isn't really suitable for testing.
A snippet of the code is as follow:
@if (Model.MealDays != null)
{
bool boolSaltLess = false;
@foreach (var c in Model.MealDays)
{
@{
if (@c.Meal.Saltless == true)
{
boolSaltLess = true;
}
}
}
<div>
<p><b>Missing meal diets:</b></p>
@if (boolSaltLess == false)
{
<p style="color:red">A saltless meal!</p>
}
</div>
}
My initial question is if I could move this code into my controller, and what result I would need to return from my controller to display this information in my View.
Aucun commentaire:
Enregistrer un commentaire