Enumeration of units, quantity class and ingredient class are finished. Unit test of the ingredient class are done. I'm going to test them in the stub
continuous-integration/drone/push Build is failing Details

pull/47/head
Roxane 2 years ago
parent e3d83292b8
commit 649ed6f72f

@ -9,38 +9,55 @@ namespace Model
internal class Ingredient
{
#region Attributes
/// <summary>
/// Name of the ingredient
/// </summary>
private string name;
/// <summary>
/// get the quatity of ingredient
/// </summary>
private Quantity quantity;
private string name = "";
private Quantity quantity = new Quantity(1, Unit.unit) ;
#endregion
#region
/// <summary>
/// Property of the Ingredient's attribute name. It raises an ArgumentNullException to prevent a nullable field.
/// </summary>
public string Name
{
get => name;
set
set
{
if (value == null)
if (value == null)
{
throw new ArgumentNullException("Impossible de ne pas avoir de nom pour l'ingrédient");
}
}
}
public Quantity QuantityP
/// <summary>
/// Property of the Ingredient's attribute Quantity.
/// </summary>
public Quantity QuantityI
{
get => quantity;
set => quantity = value;
}
public bool Equals(Ingredient? other)
{
if (other == null) { return false; }
if (this == other) { return true; }
return Name.Equals(other.Name);
}
#endregion
#region Constructor
public Ingredient(string name, Quantity quantity)
{
Name = name;
QuantityI = quantity;
}
#endregion
}
}

@ -6,6 +6,10 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Quantity is a class which is associate to Ingedients. It represents the quantity of every ingredient with an enum
/// to indicate the unit of the quantity.
/// </summary>
public class Quantity
{
#region Attributes
@ -17,20 +21,41 @@ namespace Model
/// have the Unit enum of the quantity of ingredient
/// </summary>
private Unit unit;
#endregion
#endregion
/// <summary>
/// Represents the quantity in digits. The null value raise an argumentException.
/// </summary>
public int Number
{
get { return number; }
set
{
if (value <0 )
if (value < 0)
{
throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!");
}
number = value;
}
}
public Unit UnitQ
{
get => unit;
set => unit = value;
}
#region Constructor
/// <summary>
/// Constructor of Quantity
/// </summary>
/// <param name="number"></param>
/// <param name="unit"></param>
public Quantity(int number, Unit unit)
{
Number = number;
UnitQ = unit;
}
#endregion
}
}

@ -32,7 +32,7 @@ namespace Model
{
StringBuilder sb = new StringBuilder();
foreach (string str in Ingredients) sb.Append("\t- " + str + "\n");
return sb.ToString();
}

@ -6,6 +6,10 @@ using System.Threading.Tasks;
namespace Model
{
public enum Unit
/// <summary>
/// Unit is an Enum that represents the units of quantities
/// <list type="Unit, kG, mG, G, L, cL, mL"/>
/// </summary>
public enum Unit
{ Unit, kG, mG, G, L, cL, mL };
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model_UnitTests
{
public class Ingredient_UT
{
public void TestConstructIngredient()
{
Quantity quantity = new Quantity(200, Unit.mL);
Ingredient patate = new Ingredient("Patate", quantity);
Assert.Equal("Patate", patate.Nom);
}
}
}
Loading…
Cancel
Save