🩹 fix merge conflicts - update projects naming
continuous-integration/drone/push Build is failing Details

pull/35/head^2
Alexandre AGOSTINHO 2 years ago
commit e75734c527

@ -14,28 +14,34 @@ steps:
path: /docs path: /docs
commands: commands:
- cd MCTG/ - cd MCTG/
- dotnet restore SAE-2.01.sln - dotnet restore ./ConsoleApp/ConsoleApp.csproj
- dotnet build SAE-2.01.sln -c Release --no-restore - dotnet restore ./Model/Model.csproj
- dotnet publish SAE-2.01.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet restore ./Tests/Model_UnitTests/Model_UnitTests.csproj
- dotnet build SAE-2.01.sln -c CI --no-restore
- dotnet publish SAE-2.01.sln -c CI --no-restore -o CI_PROJECT_DIR/build/release
- name: tests - name: tests
image: mcr.microsoft.com/dotnet/sdk:7.0 image: mcr.microsoft.com/dotnet/sdk:7.0
commands: commands:
- cd MCTG/ - cd MCTG/
- dotnet restore SAE-2.01.sln - dotnet restore ./ConsoleApp/ConsoleApp.csproj
- dotnet test SAE-2.01.sln --no-restore - dotnet restore ./Model/Model.csproj
depends_on: [build] - dotnet restore ./Tests/Model_UnitTests/Model_UnitTests.csproj
- dotnet test SAE-2.01.sln -c CI --no-restore
depends_on: [ build ]
- name: code-analysis - name: code-analysis
image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7 image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7
commands: commands:
- cd MCTG/ - cd MCTG/
- dotnet restore SAE-2.01.sln - dotnet restore ./ConsoleApp/ConsoleApp.csproj
- dotnet restore ./Model/Model.csproj
- dotnet restore ./Tests/Model_UnitTests/Model_UnitTests.csproj
- dotnet sonarscanner begin /k:SAE-2.01 /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet sonarscanner begin /k:SAE-2.01 /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
- dotnet build SAE-2.01.sln -c Release --no-restore - dotnet build SAE-2.01.sln -c CI --no-restore
- dotnet test SAE-2.01.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - dotnet test SAE-2.01.sln -c CI --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
- dotnet publish SAE-2.01.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet publish SAE-2.01.sln -c CI --no-restore -o CI_PROJECT_DIR/build/release
- dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
secrets: [ SECRET_SONAR_LOGIN ] secrets: [ SECRET_SONAR_LOGIN ]
settings: settings:

3
.gitignore vendored

@ -4,6 +4,9 @@
## ##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-spacific editor config
.editorconfig
# User-specific files # User-specific files
*.rsuser *.rsuser
*.suo *.suo

@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MCTGLib\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -0,0 +1,21 @@
// See https://aka.ms/new-console-template for more information
using ConsoleApp;
using Model;
Console.WriteLine("Hello, World!\n\n");
// TESTS:
Stub stub = new Stub();
List<Recipe> recipes = stub.LoadRecipes();
List<RecipeCollection> recipeCollections = stub.LoadRecipeCollection();
foreach (Recipe r in recipes)
Console.WriteLine(r);
foreach (RecipeCollection r in recipeCollections)
Console.WriteLine(r);

@ -0,0 +1,60 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp
{
internal struct Stub
{
public List<Recipe> LoadRecipes()
{
List<Recipe> stub = new List<Recipe>();
stub.AddRange(new[]
{
new Recipe(),
new Recipe("Cookies"),
new Recipe("Cookies", 23),
new Recipe("Cookies", null),
new Recipe("", null),
new Recipe("", 24),
new Recipe("Cookies", 24,
new PreparationStep(1)),
new Recipe("Cookies", 26,
new PreparationStep(1),
new PreparationStep(2, "Faire cuire."))
});
return stub;
}
public List<RecipeCollection> LoadRecipeCollection()
{
List<RecipeCollection> stub = new List<RecipeCollection>();
stub.AddRange(new[]
{
new RecipeCollection("All", LoadRecipes().ToArray()),
new RecipeCollection("Starters", LoadRecipes().FindAll(x => x.Id.Equals(23)).ToArray()),
new RecipeCollection("Dishies", LoadRecipes().FindAll(x => x.Id.Equals(24)).ToArray()),
new RecipeCollection("Desserts", LoadRecipes().FindAll(x => x.Id.Equals(26)).ToArray()),
});
return stub;
}
public List<User> ConstrucList()
{
List<User> Users = new List<User>();
User Roger = new User("Roger", "Rabbit", "carotte@mail.fr");
User Dylan = new User("d", "r", "dr@mail.fr");
User Val = new User("V", "entin", "Valentin@mail.fr");
Users.Add(Roger);
Users.Add(Dylan);
Users.Add(Val);
return Users;
}
}
}

@ -1,21 +0,0 @@
// See https://aka.ms/new-console-template for more information
using System.Runtime.InteropServices;
using MCTGLib;
Console.WriteLine("Hello, World!");
Stub stub = new Stub();
List<User> users = stub.ConstrucList();
foreach (User user in users)
{
try
{
Console.WriteLine(user.Name);
Console.WriteLine(user.Priorities[0].ToString());
} catch (ArgumentException erreurNomVide)
{
Console.WriteLine(erreurNomVide.Message);
}
}

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class PasswordManager : IPasswordManager
{
}
}

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace MCTGLib
{
public class Stub
{
public List<User> ConstrucList()
{
List<User> Users = new List<User>();
User Roger = new User("Roger", "Rabbit", "carotte@mail.fr");
User Dylan = new User("d", "r", "dr@mail.fr");
User Val = new User("V", "entin", "Valentin@mail.fr");
Users.Add(Roger);
Users.Add(Dylan);
Users.Add(Val);
return Users;
}
}
}

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Define a step of the preparation of a recipe.
/// </summary>
public class PreparationStep : IEquatable<PreparationStep>
{
#region Attributes
private string _description = "";
#endregion
#region Properties
/// <summary>
/// The order of this step in the preparation of the meal.
/// </summary>
public int Order { get; init; }
/// <summary>
/// The description of the task the user need to do for this step of the preparation. <br/>
/// Set to "No description." when the value passed is null, empty or contain white spaces.
/// </summary>
public string Description
{
get => _description;
private set
{
if (string.IsNullOrWhiteSpace(value))
_description = "No description.";
else
_description = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Construct a new step of preparation.
/// </summary>
/// <param name="order">The number of the order in preparation</param>
/// <param name="description">The description of the task</param>
public PreparationStep(int order, string description = "")
{
Order = order;
Description = description;
}
#endregion
#region Methods
public virtual bool Equals(PreparationStep? other)
{
if (other == null) return false;
if (other == this) return true;
return Order.Equals(other.Order) && Description.Equals(other.Description);
}
public override bool Equals(object? obj)
{
var item = obj as PreparationStep;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return Order.GetHashCode() + Description.GetHashCode();
}
public override string ToString()
{
return $"{Order}- {Description}";
}
#endregion
}
}

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
namespace Model
{
/// <summary>
/// Define a Recipe for the preparation of a meal.
/// </summary>
public class Recipe : IEquatable<Recipe>
{
#region Attributes
private string _title = "";
#endregion
#region Properties
/// <summary>
/// The ID of the recipe - allows you to compare and/or get this item in an easier way.
/// </summary>
public int Id { get; init; }
/// <summary>
/// The Title of the recipe. <br/>
/// Set to "No title." when the value passed is null, empty or contain white spaces.
/// </summary>
public string Title
{
get => _title;
set
{
if (string.IsNullOrWhiteSpace(value))
_title = "No title.";
else
_title = value;
}
}
/// <summary>
/// The steps of the preparation. See: <see cref="PreparationStep"/>.
/// </summary>
public List<PreparationStep> PreparationSteps { get; set; }
#endregion
#region Constructors
/// <summary>
/// Construct a new recipe.
/// </summary>
/// <param name="title">The title of the recipe</param>
/// <param name="id">The id of the recipe. If not given, get a new id.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal</param>
public Recipe(string title = "", int? id = null,
params PreparationStep[] preparationSteps)
{
Title = title;
PreparationSteps = new List<PreparationStep>(preparationSteps);
if (id == null)
{
var randomGenerator = RandomNumberGenerator.Create();
byte[] data = new byte[16];
randomGenerator.GetBytes(data);
Id = Math.Abs(BitConverter.ToInt16(data));
}
else Id = (int)id;
}
#endregion
#region Methods
public virtual bool Equals(Recipe? other)
{
if (other == null) return false;
if (other == this) return true;
return Title.Equals(other.Title) && PreparationSteps.Equals(other.PreparationSteps);
}
public override bool Equals(object? obj)
{
var item = obj as Recipe;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return Id.GetHashCode();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder($"[Recipe n°{Id}] - {Title}\n");
foreach (PreparationStep ps in PreparationSteps)
{
sb.AppendFormat("\t* {0}\n", ps.ToString());
}
return sb.ToString();
}
#endregion
}
}

@ -0,0 +1,154 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace Model
{
/// <summary>
/// Define a collection of <see cref="Recipe"/>.
/// <br/>This class implement <see cref="IList"/> and <see cref="IEquatable{T}"/>.
/// </summary>
public class RecipeCollection : IList<Recipe>, IEquatable<RecipeCollection>
{
#region Attributes
private readonly List<Recipe> _recipes;
private string _description = "";
#endregion
#region Properties
/// <summary>
/// A short description of what this collection contain. <br/>
/// Set to "No description." when the value passed is null, empty or contain white spaces.
/// </summary>
public string Description
{
get => _description;
set
{
if (string.IsNullOrWhiteSpace(value))
_description = "No description.";
else
_description = value;
}
}
#region IList Prperties
public int Count => _recipes.Count;
public bool IsReadOnly => false;
public Recipe this[int index] { get => _recipes[index]; set => _recipes[index] = value; }
#endregion
#endregion
#region Constructors
/// <summary>
/// Construct a new collection of _recipes.
/// </summary>
/// <param name="description">A short description of what this list will contain</param>
/// <param name="recipes">Recipes to add in this new collection</param>
public RecipeCollection(string description, params Recipe[] recipes)
{
_recipes = new List<Recipe>(recipes);
Description = description;
}
#endregion
#region Methods
/// <summary>
/// Find a recipe in this list by giving the id.
/// </summary>
/// <param name="id">The id of the list we are looking for</param>
/// <returns>The recipe of the id given</returns>
/// <exception cref="ArgumentException"/>
public Recipe? GetRecipeById(int id)
{
Recipe? recipe = _recipes.Find(r => r.Id == id);
if (recipe == null) throw new ArgumentException("No _recipes match the given id.");
return recipe;
}
#region IList Methods
public int IndexOf(Recipe item)
{
return _recipes.IndexOf(item);
}
public void Insert(int index, Recipe item)
{
_recipes.Insert(index, item);
}
public void RemoveAt(int index)
{
_recipes.RemoveAt(index);
}
public void Add(Recipe item)
{
_recipes.Add(item);
}
public void Clear()
{
_recipes.Clear();
}
public bool Contains(Recipe item)
{
return _recipes.Contains(item);
}
public void CopyTo(Recipe[] array, int arrayIndex)
{
_recipes.CopyTo(array, arrayIndex);
}
public bool Remove(Recipe item)
{
return _recipes.Remove(item);
}
public IEnumerator<Recipe> GetEnumerator()
{
return _recipes.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _recipes.GetEnumerator();
}
#endregion
public virtual bool Equals(RecipeCollection? other)
{
if (other == null) return false;
if (other == this) return true;
return _description.Equals(other.Description) && _recipes.Equals(other._recipes);
}
public override bool Equals(object? obj)
{
var item = obj as RecipeCollection;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return _recipes.GetHashCode();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder($"[RecipeCollection] - {Description}:\n");
foreach (Recipe r in _recipes)
{
sb.AppendFormat("\t - {0}\n", r.ToString());
}
return sb.ToString();
}
#endregion
}
}

@ -1,5 +1,4 @@
using MCTGLib; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class PasswordManager : IPasswordManager
{
public void changePassword(User user, string newPassword)
{
throw new NotImplementedException();
}
public string HashPassword(User user)
{
throw new NotImplementedException();
}
public bool VerifyPassword(string hashedPassword)
{
throw new NotImplementedException();
}
}
}

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MCTGLib namespace Model
{ {
/// <summary> /// <summary>
/// This is the list of priorities that user can define in his profil. Priorities /// This is the list of priorities that user can define in his profil. Priorities

@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace MCTGLib namespace Model
{ {
/// <summary> /// <summary>
/// A user is an entity with a name, a surname, mail, profilePict and a list of priority. /// A user is an entity with a name, a surname, mail, profilePict and a list of priority.
@ -111,9 +111,9 @@ namespace MCTGLib
set=> priorities = value; set=> priorities = value;
} }
public bool Equals(User other) public bool Equals(User other)
{ {
return Name.Equals(other.Name) && Surname.Equals(other.Surname) && Mail.Equals(other.Mail) && ; return Name.Equals(other.Name) && Surname.Equals(other.Surname) && Mail.Equals(other.Mail);
} }

@ -3,28 +3,44 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290 VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "MCTGApp\ConsoleApp.csproj", "{666C2211-8EBB-4FC8-9484-CB93BC854153}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{666C2211-8EBB-4FC8-9484-CB93BC854153}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "MCTGLib\Model.csproj", "{42FF86BD-92F9-4A32-A938-68515905378F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{42FF86BD-92F9-4A32-A938-68515905378F}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MCTGLib_UnitTests", "Tests\MCTGLib_UnitTests\MCTGLib_UnitTests.csproj", "{45AB746A-194B-4E43-81EB-83B06F35AA33}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Views", "Views\Views.csproj", "{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model_UnitTests", "Tests\Model_UnitTests\Model_UnitTests.csproj", "{45AB746A-194B-4E43-81EB-83B06F35AA33}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
CI|Any CPU = CI|Any CPU
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{666C2211-8EBB-4FC8-9484-CB93BC854153}.CI|Any CPU.ActiveCfg = Release|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.CI|Any CPU.Build.0 = Release|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.Build.0 = Debug|Any CPU {666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.Build.0 = Debug|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.ActiveCfg = Release|Any CPU {666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.ActiveCfg = Release|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.Build.0 = Release|Any CPU {666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.Build.0 = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.CI|Any CPU.ActiveCfg = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.CI|Any CPU.Build.0 = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.Build.0 = Debug|Any CPU {42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.ActiveCfg = Release|Any CPU {42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.Build.0 = Release|Any CPU {42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.Build.0 = Release|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.CI|Any CPU.ActiveCfg = CI|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.Build.0 = Release|Any CPU
{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.Deploy.0 = Release|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.CI|Any CPU.ActiveCfg = Release|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.CI|Any CPU.Build.0 = Release|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU {45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU {45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU

@ -22,8 +22,13 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<<<<<<< HEAD:MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\MCTGLib\Model.csproj" /> <ProjectReference Include="..\..\MCTGLib\Model.csproj" />
=======
<ItemGroup>
<ProjectReference Include="..\..\Model\Model.csproj" />
>>>>>>> dev-model:MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -0,0 +1,26 @@
using Model;
namespace Model_UnitTests
{
public class Recipe_UT
{
[Fact]
public void TestVoidConstructor()
{
Recipe r = new Recipe(id: 999); // id is given to avoid tests errors with the static atrribute 'idCreator'.
Assert.NotNull(r.Title);
}
[Theory]
[InlineData("Cookies", 23, "Cookies", 23)]
[InlineData("Cookies", 1, "Cookies", 1)]
[InlineData("No title.", 1, "", 1)]
public void TestConstructor(string expectedTitle, int expectedId, string title, int? id)
{
Recipe r = new Recipe(title, id);
Assert.NotNull(r.Title);
Assert.Equal(expectedId, r.Id);
Assert.Equal(expectedTitle, r.Title);
}
}
}
Loading…
Cancel
Save