diff --git a/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs index b2c1853..4a7395a 100644 --- a/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs +++ b/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs @@ -1,5 +1,6 @@ using CalculateurApp.View; using CalculateurApp.ViewModel; +using ClassCalculateurMoyenne; namespace CalculateurApp { @@ -9,9 +10,11 @@ namespace CalculateurApp { InitializeComponent(); - MainPage = new NavigationPage(new HomePage()); + MainPage = new NavigationPage(new HomePage()); //MainPage = new AppShell(BlocViewModel c); - // MainPage = new Maquette(); + // MainPage = new Maquette (); + // MainPage = new UEPage1(); + } } } \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj b/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj index b44673b..8bcc82d 100644 --- a/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj +++ b/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj @@ -60,22 +60,31 @@ %(Filename) + + MaquettePage.xaml + + + MSBuild:Compile + MSBuild:Compile - + MSBuild:Compile MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile - + MSBuild:Compile diff --git a/src/CalculateurMoyanne/CalculateurApp/MauiProgram.cs b/src/CalculateurMoyanne/CalculateurApp/MauiProgram.cs index cda4c15..8c333a9 100644 --- a/src/CalculateurMoyanne/CalculateurApp/MauiProgram.cs +++ b/src/CalculateurMoyanne/CalculateurApp/MauiProgram.cs @@ -17,7 +17,7 @@ namespace CalculateurApp }); builder.Services.AddTransient(); builder.Services.AddTransient(); - builder.Services.AddSingleton(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml b/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml new file mode 100644 index 0000000..a15274b --- /dev/null +++ b/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml.cs new file mode 100644 index 0000000..742547e --- /dev/null +++ b/src/CalculateurMoyanne/CalculateurApp/View/EXE.xaml.cs @@ -0,0 +1,9 @@ +namespace CalculateurApp.View; + +public partial class EXE : ContentPage +{ + public EXE() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml b/src/CalculateurMoyanne/CalculateurApp/View/MaquettePage.xaml similarity index 63% rename from src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml rename to src/CalculateurMoyanne/CalculateurApp/View/MaquettePage.xaml index fba2d08..f7eea4e 100644 --- a/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml +++ b/src/CalculateurMoyanne/CalculateurApp/View/MaquettePage.xaml @@ -12,18 +12,11 @@ Padding="10" RowSpacing="10" ColumnSpacing="10"> - - - - + TextColor="Black" + /> + + + + + + + + + + + + + + + + - - - - - - - + + - + + - - + + - + - - + - @@ -129,16 +155,9 @@ - - - - - - - - + - + --> diff --git a/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml b/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml deleted file mode 100644 index 463e9a3..0000000 --- a/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml.cs deleted file mode 100644 index 8276235..0000000 --- a/src/CalculateurMoyanne/CalculateurApp/View/UE.xaml.cs +++ /dev/null @@ -1,13 +0,0 @@ -using CalculateurApp.ViewModel; - -namespace CalculateurApp.View; - -public partial class UE : ContentPage -{ - - public UE(UeViewModel u) - { - InitializeComponent(); - BindingContext = u; - } -} \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml b/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml new file mode 100644 index 0000000..78e2459 --- /dev/null +++ b/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml.cs new file mode 100644 index 0000000..63f14f9 --- /dev/null +++ b/src/CalculateurMoyanne/CalculateurApp/View/UEPage1.xaml.cs @@ -0,0 +1,12 @@ +using CalculateurApp.ViewModel; + +namespace CalculateurApp.View; + +public partial class UEPage1 : ContentPage +{ + public UEPage1() + { + InitializeComponent(); + BindingContext = new UeViewModel(); + } +} \ No newline at end of file diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs index d007085..1e36edc 100644 --- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs +++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs @@ -10,11 +10,10 @@ using System.Threading.Tasks; namespace CalculateurApp.ViewModel { - [QueryProperty("Nom", "Nom")] + // [QueryProperty("Nom", "Nom")] public partial class BlocViewModel:ObservableObject { - [ObservableProperty] - string nom; + [RelayCommand] async Task GoBack() { @@ -25,23 +24,26 @@ namespace CalculateurApp.ViewModel public BlocViewModel() { Items = new ObservableCollection(); - blocModel=new BlocModel(); ue = new UE(); } [ObservableProperty] ObservableCollection items; + [ObservableProperty] + string intitulé; + [RelayCommand] void Add() { - if (string.IsNullOrEmpty(ue.Intitulé)) + if (string.IsNullOrEmpty(ue.Intitulé)&& string.IsNullOrEmpty(ue.Coefficient.ToString())) return; - UE u = new UE(ue.Intitulé); + UE u = new UE(ue.Intitulé,ue.Coefficient); //u.Intitulé = ue.Intitulé; Items.Add(u); ue.Intitulé = string.Empty; + ue.Coefficient = 0; } [RelayCommand] void Delete(UE bl) diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs index fa3adb6..0e4ce8d 100644 --- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs +++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs @@ -21,8 +21,6 @@ namespace CalculateurApp.ViewModel Items = new ObservableCollection(); blocModel = new BlocModel(); - - } [ObservableProperty] ObservableCollection items; diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs index f71218c..0d2ef4a 100644 --- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs +++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs @@ -1,24 +1,73 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using ClassCalculateurMoyenne; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CalculateurApp.ViewModel { - [QueryProperty("Nom", "Nom")] + // [QueryProperty("Nom", "Nom")] public partial class UeViewModel:ObservableObject { + //[ObservableProperty] + //string nom; + + //[RelayCommand] + //async Task GoBack() + //{ + // await Shell.Current.GoToAsync(".."); + //} + public UE u { get; set; } + public Matiere ma { get; set; } + + public UeViewModel() + { + Tems = new ObservableCollection(); + Items = new ObservableCollection(); + + + ma = new Matiere(); + u = new UE(); + + } [ObservableProperty] - string nom; + ObservableCollection items; + [ObservableProperty] + ObservableCollection tems; + [ObservableProperty] + string coefficient; + [ObservableProperty] + string nommatiere; + [RelayCommand] + void Add() + { + if (string.IsNullOrEmpty(ma.Nommatiere)) + return; + Matiere m = new Matiere(ma.Nommatiere); + + Items.Add(m); + ma.Nommatiere = string.Empty; + } [RelayCommand] - async Task GoBack() + void AddCoefUE() { - await Shell.Current.GoToAsync(".."); + + } + [RelayCommand] + void Delete(Matiere bl) + { + if (Items.Contains(bl)) + { + Items.Remove(bl); + } + } + } } diff --git a/src/CalculateurMoyanne/CalculateurEF/clacul.db-shm b/src/CalculateurMoyanne/CalculateurEF/clacul.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/src/CalculateurMoyanne/CalculateurEF/clacul.db-shm and /dev/null differ diff --git a/src/CalculateurMoyanne/CalculateurEF/clacul.db-wal b/src/CalculateurMoyanne/CalculateurEF/clacul.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs index a884d3f..13514e4 100644 --- a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs +++ b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs @@ -63,9 +63,9 @@ namespace CalculateurMapping bool result = false; using (var context = new CalculContext()) { - BlocEntity entity = context.Bloc.Find(data.id); + BlocEntity entity = context.Bloc.Find(data.Id); entity.Nom = data.Nom ; - entity.UE = data.ue.Select(j => new UEentity + entity.ue = data.ue.Select(j => new UEentity { intitulé = j.Intitulé, }).ToList(); diff --git a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs index 3df22a8..2f4f947 100644 --- a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs +++ b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs @@ -11,9 +11,9 @@ using System.Threading.Tasks; namespace CalculateurMapping { - public class MaquetteDbDataManager : IDataManager + public class MaquetteDbDataManager : IDataManager { - public async Task Add(Maquette mqt) + public async Task Add(MaquetteModel mqt) { bool result = false; using (var context = new CalculContext()) @@ -41,7 +41,7 @@ namespace CalculateurMapping } - public async Task Delete(Maquette maquette) + public async Task Delete(MaquetteModel maquette) { bool result = false; using (var context = new CalculContext()) @@ -54,11 +54,11 @@ namespace CalculateurMapping return result; } - public async Task> GetAll() + public async Task> GetAll() { using (var context = new CalculContext()) { - return await context.Maquettes.Select(e => new Maquette + return await context.Maquettes.Select(e => new MaquetteModel ( e.Id, e.NomMaquette, e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray() @@ -66,11 +66,11 @@ namespace CalculateurMapping } } - public async Task GetDataWithName(string name) + public async Task GetDataWithName(string name) { using (var context = new CalculContext()) { - return await context.Maquettes.Where(e => e.NomMaquette == name).Select(e => new Maquette + return await context.Maquettes.Where(e => e.NomMaquette == name).Select(e => new MaquetteModel ( e.Id, e.NomMaquette, @@ -79,7 +79,7 @@ namespace CalculateurMapping } } - public async Task Update(Maquette data) + public async Task Update(MaquetteModel data) { bool result = false; using (var context = new CalculContext()) diff --git a/src/CalculateurMoyanne/CalculateurMoyanne_sansMaui.sln b/src/CalculateurMoyanne/CalculateurMoyanne_sansMaui.sln new file mode 100644 index 0000000..18e4a62 --- /dev/null +++ b/src/CalculateurMoyanne/CalculateurMoyanne_sansMaui.sln @@ -0,0 +1,61 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31611.283 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCalculateurMoyanne", "..\Tests\TestCalculateurMoyanne\TestCalculateurMoyanne.csproj", "{707F316F-3141-4201-82FA-76E8B1E6A16C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassCalculateurMoyenne", "ClassCalculateurMoyenne\ClassCalculateurMoyenne.csproj", "{546A7EF0-BA4F-44A5-A4C3-2B173703A417}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubCalculateur", "CalculateurStub\StubCalculateur.csproj", "{FF7D3A70-4FDD-47BF-859E-A25F88593F62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculateurEF", "CalculateurEF\CalculateurEF.csproj", "{E265F701-B0ED-4EFF-ADAF-17B3E65E007F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculateurMapping", "CalculateurMapping\CalculateurMapping.csproj", "{2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSN", "BSN\BSN.csproj", "{EE834623-6D68-4016-94B9-FF3AC58C0E15}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "testttt", "testttt\testttt.csproj", "{3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {707F316F-3141-4201-82FA-76E8B1E6A16C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {707F316F-3141-4201-82FA-76E8B1E6A16C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {707F316F-3141-4201-82FA-76E8B1E6A16C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {707F316F-3141-4201-82FA-76E8B1E6A16C}.Release|Any CPU.Build.0 = Release|Any CPU + {546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Debug|Any CPU.Build.0 = Debug|Any CPU + {546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Release|Any CPU.ActiveCfg = Release|Any CPU + {546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Release|Any CPU.Build.0 = Release|Any CPU + {FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Release|Any CPU.Build.0 = Release|Any CPU + {E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Release|Any CPU.Build.0 = Release|Any CPU + {2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Release|Any CPU.Build.0 = Release|Any CPU + {EE834623-6D68-4016-94B9-FF3AC58C0E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE834623-6D68-4016-94B9-FF3AC58C0E15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE834623-6D68-4016-94B9-FF3AC58C0E15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE834623-6D68-4016-94B9-FF3AC58C0E15}.Release|Any CPU.Build.0 = Release|Any CPU + {3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} + EndGlobalSection +EndGlobal diff --git a/src/CalculateurMoyanne/CalculateurStub/Stub/StubMaquette.cs b/src/CalculateurMoyanne/CalculateurStub/Stub/StubMaquette.cs index 392e6bc..7222040 100644 --- a/src/CalculateurMoyanne/CalculateurStub/Stub/StubMaquette.cs +++ b/src/CalculateurMoyanne/CalculateurStub/Stub/StubMaquette.cs @@ -12,9 +12,9 @@ namespace StubCalculateur.Stub { private List listb = new List(); public List ues = new List(); - private List lstmqt = new List(); + private List lstmqt = new List(); - public bool Delete(Maquette data) + public bool Delete(MaquetteModel data) { if (data != null) { @@ -23,7 +23,7 @@ namespace StubCalculateur.Stub } return false; } - public bool Add(Maquette data) + public bool Add(MaquetteModel data) { if(data != null) { @@ -33,11 +33,29 @@ namespace StubCalculateur.Stub return false; } - public IEnumerable GetAll() + public async Task> GetAll() { return lstmqt; } - public IEnumerable GetAllUeBloc(int n = 10) + public async Task> GetAllMaquette(int n = 10) + { + for (int i = 0; i < n; i++) + { + Add(new MaquetteModel("Maquette " + i + 1)); + } + return lstmqt; + } + public async Task Update(MaquetteModel data) + { + if (data != null) + { + + int index = lstmqt.FindIndex(x => x.BLOCS == data.BLOCS); + lstmqt[index] = data; + } + return false; + } + public IEnumerable GetAllUeBloc(int n = 10) { for (int i = 0; i < n; i++) { diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs index 451e9ca..961fdcb 100644 --- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs +++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs @@ -44,6 +44,10 @@ namespace ClassCalculateurMoyenne this.uEs = uEs; } + public BlocModel() + { + } + private IEnumerable Ajouterue(params UE[] ues) { List result = new(); diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Maquette.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs similarity index 65% rename from src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Maquette.cs rename to src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs index f78965c..55c463d 100644 --- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Maquette.cs +++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace ClassCalculateurMoyenne { - public class Maquette + public class MaquetteModel:IEquatable { public int Id; public ReadOnlyCollection UES { get; set; } @@ -21,19 +21,25 @@ namespace ClassCalculateurMoyenne private readonly List blocs = new List(); private object value; - public Maquette(List u, List blc) + public MaquetteModel(List u, List blc) { UES = new ReadOnlyCollection(u); BLOCS = new ReadOnlyCollection(blc); } - public Maquette(long id,string nomMaquette, object value) + public MaquetteModel(long id,string nomMaquette, object value) { Id = Id; NomMaquette = nomMaquette; this.value = value; } + public MaquetteModel( string nomMaquette) + { + + NomMaquette = nomMaquette; + + } public void supprimer(UE e) { @@ -84,7 +90,28 @@ namespace ClassCalculateurMoyenne return false; } + public bool Equals(MaquetteModel other) + { + return Equals(other.NomMaquette); + } + public override bool Equals(object obj) + { + if (ReferenceEquals(obj, null)) return false; + if (ReferenceEquals(obj, this)) return true; + if (GetType() != obj.GetType()) return false; + return Equals(obj as UE); + } + public MaquetteModel(string nomMaquette, int id) + + { + NomMaquette = nomMaquette; + Id = id; + } + public void setNomMaquete(string nom) + { + NomMaquette =nom; + } } } diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Matiere.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Matiere.cs index 26f1ea9..225c916 100644 --- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Matiere.cs +++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/Matiere.cs @@ -1,4 +1,5 @@ -using System; +using CommunityToolkit.Mvvm.ComponentModel; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,13 +7,17 @@ using System.Threading.Tasks; namespace ClassCalculateurMoyenne { - public class Matiere + public class Matiere { public long Id { get; set; } + public string Nommatiere { get; set; } public int Note { get; set; } public int Coef { get; set; } + public Matiere() + { + } public Matiere(long id ,int note, string nommatiere, int coef) { Id = id; diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs index 813fff0..e5eb76a 100644 --- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs +++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs @@ -7,7 +7,8 @@ namespace ClassCalculateurMoyenne { public long Id { get; set; } public ReadOnlyCollection Matieres { get; private set; } private readonly List matieres = new List(); - public int Coefficient { get; set; } + [ObservableProperty] + private int coefficient; [ObservableProperty] private string intitulé; @@ -36,8 +37,11 @@ namespace ClassCalculateurMoyenne } public UE() { } - public UE(string intitulé, int coefficient) : this(intitulé) + public UE(string intitulé, int coefficient) + { + Intitulé = intitulé; + Coefficient = coefficient; } public override string ToString() diff --git a/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestBloc.cs b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestBloc.cs new file mode 100644 index 0000000..5a5f1f4 --- /dev/null +++ b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestBloc.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TestCalculateurMoyanne.LesTests +{ + public class UnitTestBloc + { + } +} diff --git a/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestMaquette.cs b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestMaquette.cs new file mode 100644 index 0000000..4ce6843 --- /dev/null +++ b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestMaquette.cs @@ -0,0 +1,80 @@ +using ClassCalculateurMoyenne; +using StubCalculateur.Stub; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TestCalculateurMoyanne.LesTests +{ + public class UnitTestMaquette + { + MaquetteModel m = new MaquetteModel("L3"); + [Fact] + public void Test() + { + Assert.NotNull(m); + Assert.Equal("L3", m.NomMaquette); + Assert.NotEqual("E3", m.NomMaquette); + } + [Fact] + public void TestInvalidMaquette() + { + + Assert.Throws(() => new MaquetteModel(null)); + + } + public class maquette_InlineData + { + [Theory] + [InlineData(false, "L6", 2, "L3", 2)] + [InlineData(false, "", 0, "", 0)] + [InlineData(true, "M1", 0, "M1", 0)] + + + public void TestConstructor(bool isValid, string expectedNomMaquette, int expectedId, + string NomMaquette, int id) + { + if (!isValid) + { + Assert.Throws( + () => new UE(NomMaquette, id)); + return; + } + + MaquetteModel m = new MaquetteModel(NomMaquette, id); + Assert.Equal(expectedNomMaquette, m.NomMaquette); + Assert.Equal(expectedId, m.Id); + } + // test avec stub + + [Fact] + public void TestMaquetteStub() + { + StubMaquette stub = new StubMaquette(); + Assert.Equal(10, stub.GetAllMaquette(10).Result.Count()); + } + [Fact] + public void TestRemove() + { + StubMaquette stub = new StubMaquette(); + MaquetteModel e = new MaquetteModel("L1"); + stub.Add(e); + stub.Delete(e); + //Compter le nombre de Maq dans un objet IEnumerable + Assert.Equal(0, stub.GetAll().Result.Count()); + } + public void TestUpdate() + { + StubMaquette stub = new StubMaquette(); + MaquetteModel e = new MaquetteModel("E1"); + stub.Add(e); + e.setNomMaquete ("L1"); + stub.Update(e); + Assert.Equal("L1", stub.GetAll().Result.First().NomMaquette); + } + + } + } +} diff --git a/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestUE.cs b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestUE.cs index 47f7c72..2c2b54a 100644 --- a/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestUE.cs +++ b/src/Tests/TestCalculateurMoyanne/LesTests/UnitTestUE.cs @@ -11,14 +11,10 @@ namespace TestCalculateurMoyanne.LesTests { public class UnitTestUE { - - UE e = new UE("E2"); - private bool isEqual; [Fact] - public void Test() { Assert.NotNull(e);