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 internal class Ingredient
{ {
#region Attributes #region Attributes
/// <summary>
/// Name of the ingredient private string name = "";
/// </summary> private Quantity quantity = new Quantity(1, Unit.unit) ;
private string name;
/// <summary>
/// get the quatity of ingredient
/// </summary>
private Quantity quantity;
#endregion #endregion
#region #region
/// <summary>
/// Property of the Ingredient's attribute name. It raises an ArgumentNullException to prevent a nullable field.
/// </summary>
public string Name public string Name
{ {
get => 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"); 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; get => quantity;
set => quantity = value; set => quantity = value;
} }
public bool Equals(Ingredient? other)
{
if (other == null) { return false; }
if (this == other) { return true; }
return Name.Equals(other.Name);
}
#endregion #endregion
#region Constructor
public Ingredient(string name, Quantity quantity)
{
Name = name;
QuantityI = quantity;
}
#endregion
} }
} }

@ -6,6 +6,10 @@ using System.Threading.Tasks;
namespace Model 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 public class Quantity
{ {
#region Attributes #region Attributes
@ -19,18 +23,39 @@ namespace Model
private Unit unit; private Unit unit;
#endregion #endregion
/// <summary>
/// Represents the quantity in digits. The null value raise an argumentException.
/// </summary>
public int Number public int Number
{ {
get { return number; } get { return number; }
set set
{ {
if (value <0 ) if (value < 0)
{ {
throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!"); throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!");
} }
number = value; 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
} }
} }

@ -6,6 +6,10 @@ using System.Threading.Tasks;
namespace Model 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 }; { 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