Код: Выделить всё
using NUnit.Framework;
using RecipeApplication;
namespace RecipeApp_UnitTest
{
[TestFixture]
public class RecipeTests
{
[Test]
public void TestTotalCaloriesCalculation()
{
// Arrange
Recipe recipe = new Recipe();
// Add ingredients
recipe.EnterRecipeDetails();
// Calculate expected total calories
double expectedTotalCalories = 0;
foreach (var ingredient in recipe.ingredients)
{
expectedTotalCalories += ingredient.Calories * ingredient.Quantity;
}
// Act
double actualTotalCalories = recipe.totalCalories;
// Assert
Assert.AreEqual(expectedTotalCalories, actualTotalCalories);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... it-framewo