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,18 +9,16 @@ 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;
@ -33,14 +31,33 @@ namespace Model
}
}
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
@ -19,7 +23,9 @@ namespace Model
private Unit unit;
#endregion
/// <summary>
/// Represents the quantity in digits. The null value raise an argumentException.
/// </summary>
public int Number
{
get { return number; }
@ -32,5 +38,24 @@ namespace Model
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
{
/// <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