diff --git a/.drone.yml b/.drone.yml index 04a7d3d..4e68727 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,28 +14,34 @@ steps: path: /docs commands: - cd MCTG/ - - dotnet restore SAE-2.01.sln - - dotnet build SAE-2.01.sln -c Release --no-restore - - dotnet publish SAE-2.01.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet restore ./ConsoleApp/ConsoleApp.csproj + - dotnet restore ./Model/Model.csproj + - 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 image: mcr.microsoft.com/dotnet/sdk:7.0 commands: - cd MCTG/ - - dotnet restore SAE-2.01.sln - - dotnet test SAE-2.01.sln --no-restore - depends_on: [build] + - dotnet restore ./ConsoleApp/ConsoleApp.csproj + - dotnet restore ./Model/Model.csproj + - dotnet restore ./Tests/Model_UnitTests/Model_UnitTests.csproj + - dotnet test SAE-2.01.sln -c CI --no-restore + depends_on: [ build ] - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7 commands: - 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 build SAE-2.01.sln -c Release --no-restore - - dotnet test SAE-2.01.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - dotnet build SAE-2.01.sln -c CI --no-restore + - 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" - - 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} secrets: [ SECRET_SONAR_LOGIN ] settings: diff --git a/.gitignore b/.gitignore index 4a3a6d3..6c1ac87 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ ## ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore +# User-spacific editor config +.editorconfig + # User-specific files *.rsuser *.suo diff --git a/MCTG/MCTGApp/ConsoleApp.csproj b/MCTG/ConsoleApp/ConsoleApp.csproj similarity index 81% rename from MCTG/MCTGApp/ConsoleApp.csproj rename to MCTG/ConsoleApp/ConsoleApp.csproj index 0f99933..c7f3ecd 100644 --- a/MCTG/MCTGApp/ConsoleApp.csproj +++ b/MCTG/ConsoleApp/ConsoleApp.csproj @@ -7,8 +7,8 @@ enable - - + + diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs new file mode 100644 index 0000000..773f61b --- /dev/null +++ b/MCTG/ConsoleApp/Program.cs @@ -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 recipes = stub.LoadRecipes(); +List recipeCollections = stub.LoadRecipeCollection(); + +foreach (Recipe r in recipes) + Console.WriteLine(r); + +foreach (RecipeCollection r in recipeCollections) + Console.WriteLine(r); diff --git a/MCTG/ConsoleApp/Stub.cs b/MCTG/ConsoleApp/Stub.cs new file mode 100644 index 0000000..bb8fa01 --- /dev/null +++ b/MCTG/ConsoleApp/Stub.cs @@ -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 LoadRecipes() + { + List stub = new List(); + 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 LoadRecipeCollection() + { + List stub = new List(); + 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 ConstrucList() + { + List Users = new List(); + + 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; + } + } +} diff --git a/MCTG/MCTGApp/Program.cs b/MCTG/MCTGApp/Program.cs deleted file mode 100644 index deb6134..0000000 --- a/MCTG/MCTGApp/Program.cs +++ /dev/null @@ -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 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); - } -} \ No newline at end of file diff --git a/MCTG/MCTGLib/PasswordManager.cs b/MCTG/MCTGLib/PasswordManager.cs deleted file mode 100644 index 2ed6017..0000000 --- a/MCTG/MCTGLib/PasswordManager.cs +++ /dev/null @@ -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 - { - } -} diff --git a/MCTG/MCTGLib/Stub.cs b/MCTG/MCTGLib/Stub.cs deleted file mode 100644 index 273d17b..0000000 --- a/MCTG/MCTGLib/Stub.cs +++ /dev/null @@ -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 ConstrucList() - { - List Users = new List(); - - 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; - } - } -} diff --git a/MCTG/MCTGLib/Model.csproj b/MCTG/Model/Model.csproj similarity index 100% rename from MCTG/MCTGLib/Model.csproj rename to MCTG/Model/Model.csproj diff --git a/MCTG/Model/Recipes/PreparationStep.cs b/MCTG/Model/Recipes/PreparationStep.cs new file mode 100644 index 0000000..95d15ca --- /dev/null +++ b/MCTG/Model/Recipes/PreparationStep.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + /// + /// Define a step of the preparation of a recipe. + /// + public class PreparationStep : IEquatable + { + #region Attributes + private string _description = ""; + #endregion + + #region Properties + /// + /// The order of this step in the preparation of the meal. + /// + public int Order { get; init; } + + /// + /// The description of the task the user need to do for this step of the preparation.
+ /// Set to "No description." when the value passed is null, empty or contain white spaces. + ///
+ public string Description + { + get => _description; + private set + { + if (string.IsNullOrWhiteSpace(value)) + _description = "No description."; + else + _description = value; + } + } + #endregion + + #region Constructors + /// + /// Construct a new step of preparation. + /// + /// The number of the order in preparation + /// The description of the task + 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 + } +} diff --git a/MCTG/Model/Recipes/Recipe.cs b/MCTG/Model/Recipes/Recipe.cs new file mode 100644 index 0000000..6048fdf --- /dev/null +++ b/MCTG/Model/Recipes/Recipe.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Security.Cryptography; +using System.Text; + +namespace Model +{ + /// + /// Define a Recipe for the preparation of a meal. + /// + public class Recipe : IEquatable + { + #region Attributes + private string _title = ""; + #endregion + + #region Properties + /// + /// The ID of the recipe - allows you to compare and/or get this item in an easier way. + /// + public int Id { get; init; } + + /// + /// The Title of the recipe.
+ /// Set to "No title." when the value passed is null, empty or contain white spaces. + ///
+ public string Title + { + get => _title; + set + { + if (string.IsNullOrWhiteSpace(value)) + _title = "No title."; + else + _title = value; + } + } + + /// + /// The steps of the preparation. See: . + /// + public List PreparationSteps { get; set; } + #endregion + + #region Constructors + /// + /// Construct a new recipe. + /// + /// The title of the recipe + /// The id of the recipe. If not given, get a new id. + /// The steps of the preparation of the meal + public Recipe(string title = "", int? id = null, + params PreparationStep[] preparationSteps) + { + Title = title; + PreparationSteps = new List(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 + } +} diff --git a/MCTG/Model/Recipes/RecipeCollection.cs b/MCTG/Model/Recipes/RecipeCollection.cs new file mode 100644 index 0000000..3592bb8 --- /dev/null +++ b/MCTG/Model/Recipes/RecipeCollection.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; + +namespace Model +{ + /// + /// Define a collection of . + ///
This class implement and . + ///
+ public class RecipeCollection : IList, IEquatable + { + #region Attributes + private readonly List _recipes; + private string _description = ""; + #endregion + + #region Properties + /// + /// A short description of what this collection contain.
+ /// Set to "No description." when the value passed is null, empty or contain white spaces. + ///
+ 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 + /// + /// Construct a new collection of _recipes. + /// + /// A short description of what this list will contain + /// Recipes to add in this new collection + public RecipeCollection(string description, params Recipe[] recipes) + { + _recipes = new List(recipes); + Description = description; + } + #endregion + + #region Methods + /// + /// Find a recipe in this list by giving the id. + /// + /// The id of the list we are looking for + /// The recipe of the id given + /// + 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 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 + } +} diff --git a/MCTG/MCTGLib/IPasswordManager.cs b/MCTG/Model/User/IPasswordManager.cs similarity index 87% rename from MCTG/MCTGLib/IPasswordManager.cs rename to MCTG/Model/User/IPasswordManager.cs index 2473a32..12f0e0a 100644 --- a/MCTG/MCTGLib/IPasswordManager.cs +++ b/MCTG/Model/User/IPasswordManager.cs @@ -1,17 +1,16 @@ -using MCTGLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Model -{ - public interface IPasswordManager - { - public void changePassword(User user, string newPassword); - public string HashPassword(User user); - public bool VerifyPassword(string hashedPassword); - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public interface IPasswordManager + { + public void changePassword(User user, string newPassword); + public string HashPassword(User user); + public bool VerifyPassword(string hashedPassword); + + } +} diff --git a/MCTG/Model/User/PasswordManager.cs b/MCTG/Model/User/PasswordManager.cs new file mode 100644 index 0000000..59bc784 --- /dev/null +++ b/MCTG/Model/User/PasswordManager.cs @@ -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(); + } + } +} diff --git a/MCTG/MCTGLib/Priority.cs b/MCTG/Model/User/Priority.cs similarity index 91% rename from MCTG/MCTGLib/Priority.cs rename to MCTG/Model/User/Priority.cs index 8382723..d851823 100644 --- a/MCTG/MCTGLib/Priority.cs +++ b/MCTG/Model/User/Priority.cs @@ -1,19 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MCTGLib -{ - /// - /// This is the list of priorities that user can define in his profil. Priorities - /// are also present in recipes to match the first user's priority with the recipe's priority. - /// - public enum Priority - { Economic, Fast, Easy, Light, Gourmet }; - - -} - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + /// + /// This is the list of priorities that user can define in his profil. Priorities + /// are also present in recipes to match the first user's priority with the recipe's priority. + /// + public enum Priority + { Economic, Fast, Easy, Light, Gourmet }; + + +} + + diff --git a/MCTG/MCTGLib/User.cs b/MCTG/Model/User/User.cs similarity index 94% rename from MCTG/MCTGLib/User.cs rename to MCTG/Model/User/User.cs index 27c96f1..3c6bf73 100644 --- a/MCTG/MCTGLib/User.cs +++ b/MCTG/Model/User/User.cs @@ -1,150 +1,150 @@ -using System; -using System.Collections.Generic; -using System.Collections; -using System.Collections.ObjectModel; -using System.Threading.Tasks; -using System.Runtime.CompilerServices; -using System.Text.RegularExpressions; - -namespace MCTGLib -{ - /// - /// A user is an entity with a name, a surname, mail, profilePict and a list of priority. - /// This user can login with a Id and password - /// - public class User : IEquatable - { - #region Private Attributes - - private string name=""; - private string surname=""; - private string mail = ""; - private string picture = ""; - private string password = ""; - //private string defaultUserSavePath = ""; - private List priorities; - #endregion - - #region Properties - - /// - /// Property to get Name of users and a setter - /// - /// Setter have Exception which is trigger when Name is null - public string Name - { - get { return name; } - private set - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Impossible d'avoir un champ Nom vide!"); - } - name = value; - } - } - - /// - /// Property to get Surname of users and a setter - /// - /// Setter have Exception which is trigger when Surname is null - public string Surname - { - get { return surname; } - private set - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Impossible d'avoir un champ Prénom vide!"); - } - surname = value; - } - } - - /// - /// Property to get mail of users and a setter - /// - /// User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his - /// account creation. - public string Mail - { - get { return mail; } - private init - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Impossible d'avoir un champ Email vide!"); - } - mail = value; - } - } - - /// - /// Property to initiate password, change it, and - /// - public string Password - { - get { return password; } - - set { password = value; } - } - - /// - /// For now, we define the ProfilPict as a string which is "PhotoParDefaut" - /// when the value is null. - /// - public string ProfilPict - { - get => picture; - set => picture = value; - - } - - /// - /// This is the list of priorities specific tu the user. This list is initiate - /// by default. User could change it at will. - /// - - public List Priorities - { - get => priorities; - set=> priorities = value; - } - - public bool Equals(User other) - { - return Name.Equals(other.Name) && Surname.Equals(other.Surname) && Mail.Equals(other.Mail) && ; - } - - - #endregion - - - #region Constructors - - /// - /// Construtors of user. - /// - /// The name of the user - /// The surname of the user - /// The user needs an email to login. - public User(string name, string surname, string mail) - { - Name = name; - Surname = surname; - Mail = mail; - priorities = new List { - Priority.Gourmet, - Priority.Economic, - Priority.Fast, - Priority.Light, - Priority.Easy}; - ProfilPict = picture; - - } - - #endregion - - - } -} +using System; +using System.Collections.Generic; +using System.Collections; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +namespace Model +{ + /// + /// A user is an entity with a name, a surname, mail, profilePict and a list of priority. + /// This user can login with a Id and password + /// + public class User : IEquatable + { + #region Private Attributes + + private string name=""; + private string surname=""; + private string mail = ""; + private string picture = ""; + private string password = ""; + //private string defaultUserSavePath = ""; + private List priorities; + #endregion + + #region Properties + + /// + /// Property to get Name of users and a setter + /// + /// Setter have Exception which is trigger when Name is null + public string Name + { + get { return name; } + private set + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Impossible d'avoir un champ Nom vide!"); + } + name = value; + } + } + + /// + /// Property to get Surname of users and a setter + /// + /// Setter have Exception which is trigger when Surname is null + public string Surname + { + get { return surname; } + private set + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Impossible d'avoir un champ Prénom vide!"); + } + surname = value; + } + } + + /// + /// Property to get mail of users and a setter + /// + /// User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his + /// account creation. + public string Mail + { + get { return mail; } + private init + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Impossible d'avoir un champ Email vide!"); + } + mail = value; + } + } + + /// + /// Property to initiate password, change it, and + /// + public string Password + { + get { return password; } + + set { password = value; } + } + + /// + /// For now, we define the ProfilPict as a string which is "PhotoParDefaut" + /// when the value is null. + /// + public string ProfilPict + { + get => picture; + set => picture = value; + + } + + /// + /// This is the list of priorities specific tu the user. This list is initiate + /// by default. User could change it at will. + /// + + public List Priorities + { + get => priorities; + set=> priorities = value; + } + + public bool Equals(User other) + { + return Name.Equals(other.Name) && Surname.Equals(other.Surname) && Mail.Equals(other.Mail); + } + + + #endregion + + + #region Constructors + + /// + /// Construtors of user. + /// + /// The name of the user + /// The surname of the user + /// The user needs an email to login. + public User(string name, string surname, string mail) + { + Name = name; + Surname = surname; + Mail = mail; + priorities = new List { + Priority.Gourmet, + Priority.Economic, + Priority.Fast, + Priority.Light, + Priority.Easy}; + ProfilPict = picture; + + } + + #endregion + + + } +} diff --git a/MCTG/SAE-2.01.sln b/MCTG/SAE-2.01.sln index 5c32807..cbadb1d 100644 --- a/MCTG/SAE-2.01.sln +++ b/MCTG/SAE-2.01.sln @@ -3,28 +3,44 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33516.290 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 -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 -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 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + CI|Any CPU = CI|Any CPU Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection 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.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.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.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.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.Build.0 = Debug|Any CPU {45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj similarity index 82% rename from MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj rename to MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj index 66ef51e..c83505e 100644 --- a/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj +++ b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj @@ -22,8 +22,13 @@
+<<<<<<< HEAD:MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj +======= + + +>>>>>>> dev-model:MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj diff --git a/MCTG/Tests/Model_UnitTests/Recipe_UT.cs b/MCTG/Tests/Model_UnitTests/Recipe_UT.cs new file mode 100644 index 0000000..e8593a5 --- /dev/null +++ b/MCTG/Tests/Model_UnitTests/Recipe_UT.cs @@ -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); + } + } +} diff --git a/MCTG/Tests/MCTGLib_UnitTests/Usings.cs b/MCTG/Tests/Model_UnitTests/Usings.cs similarity index 100% rename from MCTG/Tests/MCTGLib_UnitTests/Usings.cs rename to MCTG/Tests/Model_UnitTests/Usings.cs diff --git a/MCTG/Tests/MCTGLib_UnitTests/test_unit_user.cs b/MCTG/Tests/Model_UnitTests/test_unit_user.cs similarity index 100% rename from MCTG/Tests/MCTGLib_UnitTests/test_unit_user.cs rename to MCTG/Tests/Model_UnitTests/test_unit_user.cs