Calculateur

master
Mamadou Elaphi ARAFA 3 years ago
parent bf797dfb91
commit 0157dc01cc

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -0,0 +1,106 @@
using ClassCalculateurMoyenne;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BSN
{
public class Manager
{
#region propriétés
public ReadOnlyCollection<MaquetteModel> maquette { get; private set; }
private readonly List<MaquetteModel> maquettes = new();
public ReadOnlyCollection<BlocModel> bloc { get; private set; }
private readonly List<BlocModel> blocs = new();
public ReadOnlyCollection<UE> ue { get; private set; }
private readonly List<UE> ues = new();
public ReadOnlyCollection<Matiere> matiere { get; private set; }
private readonly List<Matiere> matieres = new();
public IDataManager<MaquetteModel> MaquetteDbDataManager => maquetteDbDataManager;
private readonly IDataManager<MaquetteModel> maquetteDbDataManager;
public IDataManager<BlocModel> BlocDbDataManager => blocDbDataManager;
private readonly IDataManager<BlocModel> blocDbDataManager;
public IDataManager<UE> UeDbDataManager => ueDbDataManager;
private readonly IDataManager<UE> ueDbDataManager;
// private IDataManager<Matiere> matiereDbDataManager;
public IDataManager<Matiere> MatiereDbDataManager => matiereDbDataManager;
private readonly IDataManager<Matiere> matiereDbDataManager;
#endregion
#region Constructeurs
public Manager(IDataManager<MaquetteModel> maquettemanager)
{
this.maquetteDbDataManager = maquettemanager;
maquette = new ReadOnlyCollection<MaquetteModel>(maquettes);
}
public Manager(IDataManager<BlocModel>blocmanager)
{
this.blocDbDataManager = blocmanager;
bloc = new ReadOnlyCollection<BlocModel>(blocs);
}
public Manager(IDataManager<UE> UeManager)
{
this.ueDbDataManager = UeManager;
ue = new ReadOnlyCollection<UE>(ues);
}
public Manager(IDataManager<Matiere> matiereDbDataManager)
{
this.matiereDbDataManager = matiereDbDataManager;
matiere = new ReadOnlyCollection<Matiere>(matieres);
}
public Manager(IDataManager<Matiere> matiereManager,IDataManager<UE> UeManager, IDataManager<BlocModel> blocmanager, IDataManager<MaquetteModel> maquettemanager,)
{
this.matiereDbDataManager = matiereManager;
Matiere = new ReadOnlyCollection<Matiere>(matieres);
// this.maquettemanager = maquettemanager;
// MaquetteModel = new ReadOnlyCollection<MaquetteModel>(maquettes);
// this.partieDataManager = partieDataManager;
// Parties = new ReadOnlyCollection<Partie>(parties);
// this.joueurDataManager = joueurManager;
// Joueurs = new ReadOnlyCollection<Joueur>(joueurs);
}
#endregion
//public Task<bool> AddMaquette(MaquetteModel maqt)
//{
// if (MaquetteDbDataManager == null)
// {
// return Task.FromResult(false);
// }
// return MaquetteDbDataManager.Add(maqt);
//}
//public async Task<bool> Deletemqt(MaquetteModel maqt)
//{
// if (MaquetteDbDataManager == null)
// {
// return false;
// }
// return await MaquetteDbDataManager.Delete(mqt);
//}
}
}

@ -13,7 +13,7 @@ namespace CalculateurApp
MainPage = new NavigationPage(new HomePage());
//MainPage = new AppShell(BlocViewModel c);
// MainPage = new Maquette ();
// MainPage = new UEPage1();
// MainPage = new MatNote();
}
}

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
@ -75,7 +75,7 @@
<MauiXaml Update="View\MaquettePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\Matiere1.xaml">
<MauiXaml Update="View\MatNote.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\PageUe.xaml">

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tool="https://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="CalculateurApp.View.EXE"
Title="EXE">
@ -9,9 +10,9 @@
<Grid
<!--<Grid
Padding="10"
RowSpacing="600"
RowSpacing="60"
ColumnSpacing="6">
<Grid.RowDefinitions>
<RowDefinition />
@ -21,9 +22,20 @@
<ColumnDefinition />
<ColumnDefinition/>
</Grid.ColumnDefinitions >
<Grid BackgroundColor="AliceBlue">
<Label Text=" Matiere" VerticalOptions="Center" HorizontalOptions="Start"></Label>
<Label Text="Coef" Grid.Row="0" Grid.Column="1" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"></Label>
</Grid>
</Grid>
<Frame Grid.Row="0" BackgroundColor="Black"></Frame>
<Frame Grid.Row="1" BackgroundColor="Yellow"></Frame>
</Grid>-->
<ScrollView >
<VerticalStackLayout Spacing="10" >
<Label Text="rouf"></Label>
<Frame>
</Frame>
</VerticalStackLayout>
</ScrollView>
</ContentPage>

@ -9,14 +9,14 @@
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
Padding="10"
RowSpacing="10"
ColumnSpacing="10">
Padding="2"
RowSpacing="4"
ColumnSpacing="4">
<Entry Placeholder="Ajout de BLOC DANS LA MAQUETTE"
Grid.Row="1" BackgroundColor="AliceBlue"
Text="{Binding blocModel.Nom }"
TextColor="Black"
/>
/>
<Button
Command="{Binding AddCommand}"
Text="Add"
@ -24,7 +24,7 @@
Grid.Column="1">
</Button>
<Label Text="Liste des blocs" Grid.Row="2" Grid.ColumnSpan="2" FontSize="Header" HorizontalOptions="Center" TextDecorations="Underline" TextColor="Black" FontAttributes="Bold, Italic" ></Label>
<CollectionView Grid.Row="3" Grid.ColumnSpan="3" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:BlocModel }">
<SwipeView>
@ -38,7 +38,7 @@
</SwipeItems>
</SwipeView.RightItems>
<Grid Padding="0">
<Frame>
<Frame Grid.Row="1">
<Frame.GestureRecognizers >
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=TapCommand}"
@ -47,20 +47,26 @@
<Label Text="{Binding Nom}"
FontSize="10" TextColor="Black" />
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView>
</CollectionView>
<!--//<Label Text="Liste des UE dans la Bloc X " Grid.Row="3" VerticalOptions="Center" HorizontalOptions="Start"></Label>-->
<CollectionView Grid.Row="3" VerticalOptions="Center" HorizontalOptions="Start" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:BlocModel }">
<Label Text="{Binding Nom}" Grid.Row="3" VerticalOptions="Center" HorizontalOptions="Start"
FontSize="10" TextColor="Black" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate></CollectionView>
</Grid>
</ContentPage>

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CalculateurApp.View.MatNote"
Title="MatNote">
<Frame Margin="10,0,10,0" VerticalOptions="Center">
<Grid BackgroundColor="White" Padding="30,30,0,39"
RowSpacing="-400"
ColumnSpacing="10">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Entry
BackgroundColor="AliceBlue"
HorizontalOptions="Start"
VerticalOptions="Start"
WidthRequest="100"
Placeholder=" note"
/>
<Label
Grid.Column="1"
Text="/"
HorizontalOptions="Center"
/>
<Entry
Grid.Column="2"
Placeholder="SUR"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<Label Text=" MATIERE" Grid.Row="1" HorizontalOptions="Center" />
<Entry
WidthRequest="130"
Grid.Row="2"
HorizontalOptions="Center"
Placeholder="nom de la matiére"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<Label Text=" coef" Grid.Row="1" Grid.Column="2" HorizontalOptions="Center"/>
<Entry
WidthRequest="150"
Grid.Row="2"
Grid.Column="2"
Placeholder="COEFFICIENT"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<CollectionView Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Button Text="Annuler" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="110" Grid.Column="0" ></Button>
<Button Text="Ajouter" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="2" WidthRequest="110"></Button>
</Grid>
</Frame>
</ContentPage>

@ -1,8 +1,8 @@
namespace CalculateurApp.View;
public partial class Matiere1 : TabbedPage
public partial class MatNote : ContentPage
{
public Matiere1()
public MatNote()
{
InitializeComponent();
}

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CalculateurApp.View.Matiere1"
Title="Matiere1">
<ContentPage Title="mat" IconImageSource="dotnet_bot.svg" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<BoxView Color="Green" />
<Label Text="Row 0, Column 0"
HorizontalOptions="Center"
VerticalOptions="Center" />
<BoxView Grid.Column="1"
Color="Blue" />
<Label Grid.Column="1"
Text="Row 0, Column 1"
HorizontalOptions="Center"
VerticalOptions="Center" />
<BoxView Grid.Row="1"
Color="Teal" />
<Label Grid.Row="1"
Text="Rowwww 1, Column 0"
HorizontalOptions="Center"
VerticalOptions="Center" />
<BoxView Grid.Row="1"
Grid.Column="1"
Color="Purple" />
<Label Grid.Row="1"
Grid.Column="1"
Text="Row1, Column 1"
HorizontalOptions="Center"
VerticalOptions="Center" />
<BoxView Grid.Row="2"
Grid.ColumnSpan="2"
Color="Red" />
<Label Grid.Row="2"
Grid.ColumnSpan="2"
Text="Row 2, Columns 0 and 1"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
<!--<StackLayout>
<Label Text="Nom de l'examen"/>
<Entry Placeholder="note" HorizontalTextAlignment="Center"
BackgroundColor="Beige"
HorizontalOptions="Center"
WidthRequest="100"
VerticalOptions="Center"
/>
</StackLayout>-->
<!--<Grid x:Name="rgchuii" BackgroundColor="AliceBlue" >
<VerticalStackLayout Spacing="25" VerticalOptions="Center" >
<Grid>
<Label Text="Nom de l'examen"/>
<Entry Placeholder="note" HorizontalTextAlignment="Center"
BackgroundColor="Beige"
HorizontalOptions="Center"
WidthRequest="100"
VerticalOptions="Center"
/>
</Grid>
<Grid >
<Entry Placeholder="note" HorizontalTextAlignment="Center"
BackgroundColor="Beige"
HorizontalOptions="Start"
WidthRequest="100"
VerticalOptions="Center"
/>
<Entry FontAttributes="Bold"
Margin="10"
HorizontalTextAlignment="Center"
BackgroundColor="Beige"
HorizontalOptions="Start"
WidthRequest="100"
VerticalOptions="Center"
Placeholder=" note"/>
<Label FontAttributes="Bold"
Margin="100"
Grid.Column="1"
HorizontalTextAlignment="Center"
Text="/"
HorizontalOptions="Center"
WidthRequest="100"
VerticalOptions="Center"/>
<Entry Placeholder="sur" HorizontalTextAlignment="Center"
BackgroundColor="AliceBlue"
HorizontalOptions="End"
WidthRequest="100"
VerticalOptions="Center"/>
</Grid>
<Grid>
<Label Text=" Matiere"/>
<Entry Placeholder="nom de la matiére" HorizontalTextAlignment="Center"
BackgroundColor="AliceBlue"
HorizontalOptions="Center"
WidthRequest="160"
VerticalOptions="Center"/>
</Grid>
<Grid>
<Label Text=" coef"/>
<Entry Placeholder="coef" HorizontalTextAlignment="Center"
BackgroundColor="AliceBlue"
HorizontalOptions="Center"
WidthRequest="160"
VerticalOptions="Center"/>
</Grid>
<Grid>
<Button Text="Annuler" HorizontalOptions="Start" VerticalOptions="Center"></Button>
<Button Text="Ajouter" HorizontalOptions="End" VerticalOptions="Center"></Button>
</Grid>
</VerticalStackLayout>
</Grid>-->
</ContentPage>
</TabbedPage>

@ -222,6 +222,18 @@
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<CollectionView Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Button Text="Annuler" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="110" Grid.Column="0" ></Button>
<Button Text="Ajouter" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="2" WidthRequest="110"></Button>

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -16,9 +16,10 @@ namespace CalculateurEF.Context
public DbSet<UEentity> Ue { get; set; }
public DbSet<MatiereEntity> matier { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=clacul.db");
optionsBuilder.UseSqlite("Data Source=calcul.db");
}
}
}

@ -11,14 +11,16 @@ namespace CalculateurEF.Entities
#region Propriétés
public int Id { get; set; }
public string Nom { get; set; }
public ICollection<UEentity> ue { get; set; }
#endregion
#region Constructeurs
public BlocEntity()
{
ue = new List<UEentity>();
}
//public ICollection<UEentity> ue { get; set; }
//#region Constructeurs
//public BlocEntity()
//{
// ue = new List<UEentity>();
//}
#endregion
}
}

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CalculateurEF.Migrations
{
[DbContext(typeof(CalculContext))]
[Migration("20221128083948_clacul")]
partial class clacul
[Migration("20221203193812_TestCalc")]
partial class TestCalc
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -26,7 +26,7 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("MaquetteEntityid")
b.Property<int?>("MaquetteEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Nom")
@ -35,14 +35,14 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("MaquetteEntityid");
b.HasIndex("MaquetteEntityId");
b.ToTable("Bloc");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>
{
b.Property<int>("id")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
@ -50,7 +50,7 @@ namespace CalculateurEF.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("id");
b.HasKey("Id");
b.ToTable("Maquettes");
});
@ -87,9 +87,6 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("BlocEntityId")
.HasColumnType("INTEGER");
b.Property<int>("Coefficient")
.HasColumnType("INTEGER");
@ -99,8 +96,6 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("BlocEntityId");
b.ToTable("Ue");
});
@ -108,7 +103,7 @@ namespace CalculateurEF.Migrations
{
b.HasOne("CalculateurEF.Entities.MaquetteEntity", null)
.WithMany("Bloc")
.HasForeignKey("MaquetteEntityid");
.HasForeignKey("MaquetteEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
@ -118,18 +113,6 @@ namespace CalculateurEF.Migrations
.HasForeignKey("UEentityId");
});
modelBuilder.Entity("CalculateurEF.Entities.UEentity", b =>
{
b.HasOne("CalculateurEF.Entities.BlocEntity", null)
.WithMany("ue")
.HasForeignKey("BlocEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.Navigation("ue");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>
{
b.Navigation("Bloc");

@ -5,7 +5,7 @@
namespace CalculateurEF.Migrations
{
/// <inheritdoc />
public partial class clacul : Migration
public partial class TestCalc : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -14,51 +14,45 @@ namespace CalculateurEF.Migrations
name: "Maquettes",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NomMaquette = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Maquettes", x => x.id);
table.PrimaryKey("PK_Maquettes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Bloc",
name: "Ue",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nom = table.Column<string>(type: "TEXT", nullable: false),
MaquetteEntityid = table.Column<int>(type: "INTEGER", nullable: true)
Coefficient = table.Column<int>(type: "INTEGER", nullable: false),
intitulé = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bloc", x => x.Id);
table.ForeignKey(
name: "FK_Bloc_Maquettes_MaquetteEntityid",
column: x => x.MaquetteEntityid,
principalTable: "Maquettes",
principalColumn: "id");
table.PrimaryKey("PK_Ue", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Ue",
name: "Bloc",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Coefficient = table.Column<int>(type: "INTEGER", nullable: false),
intitulé = table.Column<string>(type: "TEXT", nullable: false),
BlocEntityId = table.Column<int>(type: "INTEGER", nullable: true)
Nom = table.Column<string>(type: "TEXT", nullable: false),
MaquetteEntityId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Ue", x => x.Id);
table.PrimaryKey("PK_Bloc", x => x.Id);
table.ForeignKey(
name: "FK_Ue_Bloc_BlocEntityId",
column: x => x.BlocEntityId,
principalTable: "Bloc",
name: "FK_Bloc_Maquettes_MaquetteEntityId",
column: x => x.MaquetteEntityId,
principalTable: "Maquettes",
principalColumn: "Id");
});
@ -84,35 +78,30 @@ namespace CalculateurEF.Migrations
});
migrationBuilder.CreateIndex(
name: "IX_Bloc_MaquetteEntityid",
name: "IX_Bloc_MaquetteEntityId",
table: "Bloc",
column: "MaquetteEntityid");
column: "MaquetteEntityId");
migrationBuilder.CreateIndex(
name: "IX_matier_UEentityId",
table: "matier",
column: "UEentityId");
migrationBuilder.CreateIndex(
name: "IX_Ue_BlocEntityId",
table: "Ue",
column: "BlocEntityId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "matier");
name: "Bloc");
migrationBuilder.DropTable(
name: "Ue");
name: "matier");
migrationBuilder.DropTable(
name: "Bloc");
name: "Maquettes");
migrationBuilder.DropTable(
name: "Maquettes");
name: "Ue");
}
}
}

@ -23,7 +23,7 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("MaquetteEntityid")
b.Property<int?>("MaquetteEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Nom")
@ -32,14 +32,14 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("MaquetteEntityid");
b.HasIndex("MaquetteEntityId");
b.ToTable("Bloc");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>
{
b.Property<int>("id")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
@ -47,7 +47,7 @@ namespace CalculateurEF.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("id");
b.HasKey("Id");
b.ToTable("Maquettes");
});
@ -84,9 +84,6 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("BlocEntityId")
.HasColumnType("INTEGER");
b.Property<int>("Coefficient")
.HasColumnType("INTEGER");
@ -96,8 +93,6 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("BlocEntityId");
b.ToTable("Ue");
});
@ -105,7 +100,7 @@ namespace CalculateurEF.Migrations
{
b.HasOne("CalculateurEF.Entities.MaquetteEntity", null)
.WithMany("Bloc")
.HasForeignKey("MaquetteEntityid");
.HasForeignKey("MaquetteEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
@ -115,18 +110,6 @@ namespace CalculateurEF.Migrations
.HasForeignKey("UEentityId");
});
modelBuilder.Entity("CalculateurEF.Entities.UEentity", b =>
{
b.HasOne("CalculateurEF.Entities.BlocEntity", null)
.WithMany("ue")
.HasForeignKey("BlocEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.Navigation("ue");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>
{
b.Navigation("Bloc");

@ -20,15 +20,15 @@ namespace CalculateurMapping
public async Task<bool> Delete(BlocModel bloc)
{
bool result = false;
using (var context = new CalculContext())
{
BlocEntity entity = context.Bloc.Find(bloc.Nom);
context.Bloc.Remove(entity);
result = await context.SaveChangesAsync() > 0;
//bool result = false;
//using (var context = new CalculContext())
//{
// BlocEntity entity = context.Bloc.Find(bloc.Nom);
// context.Bloc.Remove(entity);
// result = await context.SaveChangesAsync() > 0;
}
return result;
//}
return true;
}
public async Task<IEnumerable<BlocModel>> GetAll()
@ -51,8 +51,7 @@ namespace CalculateurMapping
return await context.Bloc.Where(e => e.Nom == name).Select(e => new BlocModel
(
e.Nom,
e.Nom,
e.ue.Select(j => new UE(j.intitulé)).ToArray()
)).FirstOrDefaultAsync();
}

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -20,7 +20,7 @@ namespace CalculateurMapping
{
MaquetteEntity entity = new MaquetteEntity
{
NomMaquette = mqt.NomMaquette,
NomMaquette = mqt.GetNomMaquette(),
};
for (int i = 0; i < mqt.BLOCS.Count; i++)
{
@ -46,7 +46,7 @@ namespace CalculateurMapping
bool result = false;
using (var context = new CalculContext())
{
MaquetteEntity entity = context.Maquettes.Find(maquette.NomMaquette);
MaquetteEntity entity = context.Maquettes.Find(maquette.GetNomMaquette());
context.Maquettes.Remove(entity);
result = await context.SaveChangesAsync() > 0;
@ -56,27 +56,36 @@ namespace CalculateurMapping
public async Task<IEnumerable<MaquetteModel>> GetAll()
{
using (var context = new CalculContext())
{
return await context.Maquettes.Select(e => new MaquetteModel
( e.Id,
e.NomMaquette,
e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
)).ToListAsync();
}
//using (var context = new CalculContext())
//{
// return await context.Maquettes.Select(e => new MaquetteModel
// (e.Id,
// e.NomMaquette,
// e.Bloc.Select(u =>
// u.ue.Select(uee => new UE(uee.Id, uee.Coefficient, uee.intitulé,
// uee.mat.Select(ma => new Matiere(ma.id, ma.Note,ma.Nommatiere,ma.Coef)).ToArray()
// )).ToList()
// ),
// e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
// )).ToListAsync();
//}
return null;
}
public async Task<MaquetteModel> GetDataWithName(string name)
{
using (var context = new CalculContext())
{
return await context.Maquettes.Where(e => e.NomMaquette == name).Select(e => new MaquetteModel
(
e.Id,
e.NomMaquette,
e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
)).FirstOrDefaultAsync();
}
//using (var context = new CalculContext())
//{
// return await context.Maquettes.Where(e => e.NomMaquette == name).Select(e => new MaquetteModel
// (
// // e.Id,
// //e.NomMaquette,
// //e.Bloc.Select(u => u.ue).ToList(),
// //e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
// )).FirstOrDefaultAsync();
//}
return null;
}
public async Task<bool> Update(MaquetteModel data)
@ -85,7 +94,7 @@ namespace CalculateurMapping
using (var context = new CalculContext())
{
MaquetteEntity entity = context.Maquettes.Find(data.Id);
entity.NomMaquette = data.NomMaquette;
entity.NomMaquette = data.GetNomMaquette();
entity.Bloc = data.BLOCS.Select(j => new BlocEntity
{
Nom=j.Nom,

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class MatiereDbManager : IDataManager<Matiere>
public class MatiereDbDataManager : IDataManager<Matiere>
{ //Maping entre la classe Matier et MatiereEntity
public Task<bool> Add(Matiere data)
{

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class UeDataManager : IDataManager<UE>
public class UeDbDataManager : IDataManager<UE>
{
public Task<bool> Add(UE data)
{

@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculateurMapping", "Calcu
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSN", "BSN\BSN.csproj", "{EE834623-6D68-4016-94B9-FF3AC58C0E15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testttt", "testttt\testttt.csproj", "{3030B3CE-5F2F-451A-9F07-AE2CA9351BD0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "testpourEf", "testpourEf\testpourEf.csproj", "{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -55,10 +55,10 @@ Global
{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
{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -15,42 +15,72 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculateurMapping", "Calcu
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}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject2", "TestProject2\TestProject2.csproj", "{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
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}.Debug|x64.ActiveCfg = Debug|x64
{707F316F-3141-4201-82FA-76E8B1E6A16C}.Debug|x64.Build.0 = Debug|x64
{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
{707F316F-3141-4201-82FA-76E8B1E6A16C}.Release|x64.ActiveCfg = Release|x64
{707F316F-3141-4201-82FA-76E8B1E6A16C}.Release|x64.Build.0 = Release|x64
{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}.Debug|x64.ActiveCfg = Debug|x64
{546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Debug|x64.Build.0 = Debug|x64
{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
{546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Release|x64.ActiveCfg = Release|x64
{546A7EF0-BA4F-44A5-A4C3-2B173703A417}.Release|x64.Build.0 = Release|x64
{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}.Debug|x64.ActiveCfg = Debug|x64
{FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Debug|x64.Build.0 = Debug|x64
{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
{FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Release|x64.ActiveCfg = Release|x64
{FF7D3A70-4FDD-47BF-859E-A25F88593F62}.Release|x64.Build.0 = Release|x64
{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}.Debug|x64.ActiveCfg = Debug|x64
{E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Debug|x64.Build.0 = Debug|x64
{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
{E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Release|x64.ActiveCfg = Release|x64
{E265F701-B0ED-4EFF-ADAF-17B3E65E007F}.Release|x64.Build.0 = Release|x64
{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}.Debug|x64.ActiveCfg = Debug|x64
{2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Debug|x64.Build.0 = Debug|x64
{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
{2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Release|x64.ActiveCfg = Release|x64
{2CF7DDB5-2FD8-4D80-9D5F-9C8DD12B8518}.Release|x64.Build.0 = Release|x64
{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}.Debug|x64.ActiveCfg = Debug|x64
{EE834623-6D68-4016-94B9-FF3AC58C0E15}.Debug|x64.Build.0 = Debug|x64
{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
{EE834623-6D68-4016-94B9-FF3AC58C0E15}.Release|x64.ActiveCfg = Release|x64
{EE834623-6D68-4016-94B9-FF3AC58C0E15}.Release|x64.Build.0 = Release|x64
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Debug|x64.ActiveCfg = Debug|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Debug|x64.Build.0 = Debug|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Release|Any CPU.Build.0 = Release|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Release|x64.ActiveCfg = Release|Any CPU
{B4FC7261-2A1E-41C0-B9A7-226115C67F3B}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -49,7 +49,6 @@ namespace StubCalculateur.Stub
{
if (data != null)
{
int index = lstmqt.FindIndex(x => x.BLOCS == data.BLOCS);
lstmqt[index] = data;
}
@ -67,7 +66,7 @@ namespace StubCalculateur.Stub
{
listb.Add(new BlocModel(""));
}
// lstmqt.Add(new Maquette(ues,listb));
lstmqt.Add(new MaquetteModel(ues,listb));
ues.Clear();
}
return lstmqt;

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -8,11 +8,12 @@ using System.Threading.Tasks;
namespace ClassCalculateurMoyenne
{
public partial class BlocModel : ObservableObject
public partial class BlocModel : ObservableObject,IEquatable<BlocModel>
{
[ObservableProperty]
private string nom;
public long Id;
[ObservableProperty]
private UE[] uEs;
public ReadOnlyCollection<UE> ue { get; private set; }
@ -90,5 +91,17 @@ namespace ClassCalculateurMoyenne
return false;
}
public bool Equals(BlocModel other)
{
return Equals(other.Nom);
}
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 BlocModel);
}
}
}

@ -16,28 +16,49 @@ namespace ClassCalculateurMoyenne
private readonly List<UE> ues = new List<UE>();
public ReadOnlyCollection<BlocModel> BLOCS { get; private set; }
public string NomMaquette { get; set; }
private readonly List<BlocModel> blocs = new List<BlocModel>();
private object value;
public MaquetteModel(List<UE> u, List<BlocModel> blc)
public string NomMaquette;
public string GetNomMaquette()
{
return GetNomMaquette();
}
private void SetNomMaquette(string value)
{
if (string.IsNullOrWhiteSpace(GetNomMaquette()))
{
throw new ArgumentException("Le Nom de la maquette est obligatoire");
}
}
public MaquetteModel(int id, string nomMaquette, List<UE> u, List<BlocModel> blc)
{
UES = new ReadOnlyCollection<UE>(u);
BLOCS = new ReadOnlyCollection<BlocModel>(blc);
Id = id;
NomMaquette = nomMaquette;
UES = u.AsReadOnly();
BLOCS = blc.AsReadOnly();
}
public MaquetteModel(List<UE> u, List<BlocModel> blc)
{
UES = u.AsReadOnly();
BLOCS = blc.AsReadOnly();
}
public MaquetteModel(long id,string nomMaquette, object value)
public MaquetteModel(long id,string nomMaquette)
{
Id = Id;
NomMaquette = nomMaquette;
this.value = value;
SetNomMaquette(nomMaquette);
}
public MaquetteModel( string nomMaquette)
{
NomMaquette = nomMaquette;
SetNomMaquette(nomMaquette);
}
@ -92,26 +113,30 @@ namespace ClassCalculateurMoyenne
public bool Equals(MaquetteModel other)
{
return Equals(other.NomMaquette);
return Equals(other.GetNomMaquette());
}
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);
return Equals(obj as MaquetteModel);
}
public MaquetteModel(string nomMaquette, int id)
{
NomMaquette = nomMaquette;
SetNomMaquette(nomMaquette);
Id = id;
}
public void setNomMaquete(string nom)
{
NomMaquette =nom;
SetNomMaquette(nom);
}
}
}

@ -13,12 +13,13 @@ namespace ClassCalculateurMoyenne
private string intitulé;
public UE ( long id,List<Matiere> _matieres, int coefficient, string intitulé)
public UE ( long id, int coefficient, string intitulé,params Matiere[] matieres)
{
Id = id;
Matieres = new ReadOnlyCollection<Matiere>(_matieres);
Coefficient = coefficient;
Intitulé = intitulé;
Matieres = new ReadOnlyCollection<Matiere>(matieres);
}
public void setIntitulé(string intitulé)
{
@ -52,7 +53,7 @@ namespace ClassCalculateurMoyenne
public bool Equals(UE other)
{
return Equals(other.Intitulé);
return matieres.Equals(other.matieres);
}
public override bool Equals(object obj)
{

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.console" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
namespace TestProject1
{
public class UnitTest1
{
[Fact]
public void Test1()
{
Assert.True(true);
}
}
}

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!--<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>-->
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
namespace TestProject2
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

@ -0,0 +1,14 @@
// See https://aka.ms/new-console-template for more information
using CalculateurEF.Context;
using CalculateurEF.Entities;
Console.WriteLine("Hello, World!");
namespace testpourEF
{ class Program
{
static
}
}

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BSN\BSN.csproj" />
<ProjectReference Include="..\CalculateurEF\CalculateurEF.csproj" />
<ProjectReference Include="..\CalculateurMapping\CalculateurMapping.csproj" />
<ProjectReference Include="..\ClassCalculateurMoyenne\ClassCalculateurMoyenne.csproj" />
</ItemGroup>
</Project>

@ -1,12 +1,62 @@
using System;
using ClassCalculateurMoyenne;
using StubCalculateur.Stub;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace TestCalculateurMoyanne.LesTests
{
public class UnitTestBloc
{
// BlocModel b = new BlocModel();
// [Fact]
// public void Test()
// {
// Assert.NotNull(b);
// Assert.Equal("L3", b.Nom);
// Assert.NotEqual("E3", b.Nom);
// }
// [Fact]
// public void TestInvalidBloc()
// {
// Assert.Throws<ArgumentException>(() => new BlocModel(null));
// }
// public class Bloc_InlineData
// {
// [Theory]
// [InlineData(false, "L6", 2, "L3", 2)]
// [InlineData(false, "", 0, "", 0)]
// [InlineData(true, "M1", 0, "M1", 0)]
// public void TestConstructeur(bool isValid, string expectedNom, int expectedId,
// string Nom, int id)
// {
// if (!isValid)
// {
// Assert.Throws<ArgumentException>(() => new MaquetteModel(Nom, id));
// return;
// }
// BlocModel m = new BlocModel(Nom, id);
// Assert.Equal(expectedNom, m.Nom);
// Assert.Equal(expectedId, m.Id);
// }
// [Fact]
// public void TestBlocStub()
// {
// StubBloc stub = new StubBloc();
// // Assert.Equal(10, stub.GetAllUE(10).Result.Count());
// }
// }
}
}
}

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace TestCalculateurMoyanne.LesTests
{
@ -15,37 +16,31 @@ namespace TestCalculateurMoyanne.LesTests
public void Test()
{
Assert.NotNull(m);
Assert.Equal("L3", m.NomMaquette);
Assert.NotEqual("E3", m.NomMaquette);
Assert.Equal("L3", m.GetNomMaquette());
Assert.NotEqual("E3", m.GetNomMaquette());
}
[Fact]
public void TestInvalidMaquette()
{
Assert.Throws<ArgumentException>(() => 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)
[InlineData(false, "L6" ,"L3")]
[InlineData(false, "", "")]
[InlineData(true, "M1", "M1" )]
public void TestConstructor(bool isValid, string expectedNomMaquette,
string NomMaquette)
{
if (!isValid)
{
Assert.Throws<ArgumentException>(
() => new UE(NomMaquette, id));
Assert.Throws<ArgumentException>( () => new MaquetteModel(NomMaquette));
return;
}
MaquetteModel m = new MaquetteModel(NomMaquette, id);
Assert.Equal(expectedNomMaquette, m.NomMaquette);
Assert.Equal(expectedId, m.Id);
MaquetteModel m = new MaquetteModel(NomMaquette);
Assert.Equal(expectedNomMaquette, m.GetNomMaquette());
}
// test avec stub
@ -65,16 +60,17 @@ namespace TestCalculateurMoyanne.LesTests
//Compter le nombre de Maq dans un objet IEnumerable
Assert.Equal(0, stub.GetAll().Result.Count());
}
[Fact]
public void TestUpdate()
{
StubMaquette stub = new StubMaquette();
MaquetteModel e = new MaquetteModel("E1");
stub.Add(e);
e.setNomMaquete ("L1");
e.setNomMaquete("L1");
stub.Update(e);
Assert.Equal("L1", stub.GetAll().Result.First().NomMaquette);
Assert.Equal("L1", stub.GetAll().Result.First().GetNomMaquette());
}
}
}
}

@ -2,6 +2,7 @@
using StubCalculateur.Stub;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -11,76 +12,142 @@ namespace TestCalculateurMoyanne.LesTests
{
public class UnitTestUE
{
UE e = new UE("E2");
private bool isEqual;
[Fact]
public void Test()
public static IEnumerable<object[]> Data_AddMatiereToUE()
{
Assert.NotNull(e);
Assert.Equal("E2", e.Intitulé);
Assert.NotEqual("E3", e.Intitulé);
}
[Fact]
public void TestInvalidUE()
{
Assert.Throws<ArgumentException>(() => new UE(null));
}
public class Artist_InlineData_UT
{
[Theory]
[InlineData(false, "Mathematique", 2, "MTH", 2)]
[InlineData(false, "", 0, "", 0)]
[InlineData(true, "Mathematique", 0, "Mathematique", 0)]
yield return new object[]
{
true,
new Matiere[]
{
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4),
new Matiere(4,12,"geo",2)
},
new UE(1,2,"UE2",
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4)),
new Matiere(4,12,"geo",2)
public void TestConstructor(bool isValid, string expectedMatiere, int expectedcoef,
string intitulé, int coefficient)
};
yield return new object[]
{
if (!isValid)
false,
new Matiere[]
{
Assert.Throws<ArgumentException>(
() => new UE(intitulé, coefficient));
return;
}
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4),
new Matiere(4,12,"geo",2)
},
new UE(1,2,"UE2",
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4)),
new Matiere(4,12,"geo",2),
new Matiere(5,2,"arithmetique",3)
};
}
[Theory]
[MemberData(nameof(Data_AddMatiereToUE))]
public void Test_AddMatiereToUE(bool expectedResult,
IEnumerable<Matiere> expectedMatiere,
UE ue,
Matiere matiere) {
UE e = new UE(intitulé, coefficient);
Assert.Equal(expectedMatiere,e.Intitulé);
Assert.Equal(expectedcoef, e.Coefficient);
}
// true si l'ajout est réussi et false sinon
bool result = ue.AjouterMatiere(matiere);
// test avec stub
// comparaison avec le resultat qu'on espert avoir
Assert.Equal(expectedResult, result);
//
Assert.Equal(expectedMatiere.Count(), ue.Matieres.Count());
Assert.All(expectedMatiere, j => ue.Matieres.Contains(j));
[Fact]
public void TestUeStub()
{
stubUE stub = new stubUE();
Assert.Equal(10, stub.GetAllUE(10).Result.Count());
}
[Fact]
public void TestRemove()
{
stubUE stub = new stubUE();
UE e = new UE("E1");
stub.Add(e);
stub.Delete(e);
//Compter le nombre de UE dans un objet IEnumerable
Assert.Equal(0, stub.GetAll().Result.Count());
}
public void TestUpdate()
{
stubUE stub = new stubUE();
UE e = new UE("E1");
stub.Add(e);
e.setIntitulé("UE1");
stub.Update(e);
Assert.Equal("UE1", stub.GetAll().Result.First().Intitulé);
}
}
}
}
//true,
//new Artist[]
//{
// new Artist("Miles", "Davis"),
// new Artist("Wayne", "Shorter"),
// new Artist("Herbie", "Hancock"),
// new Artist("Ron", "Carter"),
// new Artist("Tony", "Williams")
//},
//new Album("Miles Smiles", new DateTime(1967, 1, 1),
// new Artist("Miles", "Davis"),
// new Artist("Wayne", "Shorter"),
// new Artist("Herbie", "Hancock"),
// new Artist("Ron", "Carter")),
//new Artist("Tony", "Williams")
//{
// [Theory]
// [InlineData(false, "Mathematique", 2, "MTH", 2)]
// [InlineData(false, "", 0, "", 0)]
// [InlineData(true, "Mathematique", 0, "Mathematique", 0)]
// public void TestConstructor(bool isValid, string expectedMatiere, int expectedcoef,
// string intitulé, int coefficient)
// {
// if (!isValid)
// {
// Assert.Throws<ArgumentException>(
// () => new UE(intitulé, coefficient));
// return;
// }
// UE e = new UE(intitulé, coefficient);
// Assert.Equal(expectedMatiere,e.Intitulé);
// Assert.Equal(expectedcoef, e.Coefficient);
// }
// // test avec stub
// [Fact]
// public void TestUeStub()
// {
// stubUE stub = new stubUE();
// Assert.Equal(10, stub.GetAllUE(10).Result.Count());
// }
// [Fact]
// public void TestRemove()
// {
// stubUE stub = new stubUE();
// UE e = new UE("E1");
// stub.Add(e);
// stub.Delete(e);
// //Compter le nombre de UE dans un objet IEnumerable
// Assert.Equal(0, stub.GetAll().Result.Count());
// }
// public void TestUpdate()
// {
// stubUE stub = new stubUE();
// UE e = new UE("E1");
// stub.Add(e);
// e.setIntitulé("UE1");
// stub.Update(e);
// Assert.Equal("UE1", stub.GetAll().Result.First().Intitulé);
// }
//}

@ -6,19 +6,21 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<!--<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</PackageReference>-->
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save