diff --git a/notus/Biblioteque_de_Class/Note.cs b/notus/Biblioteque_de_Class/Note.cs
index a4641f4..00edf69 100644
--- a/notus/Biblioteque_de_Class/Note.cs
+++ b/notus/Biblioteque_de_Class/Note.cs
@@ -67,21 +67,26 @@ namespace Biblioteque_de_Class
}
public void AddImage(string imageLink, string position)
+ {
+ int newname = ImageList.Count() + 1;
+ ImageList.Add(new NoteImage(newname, imageLink, position));
+ }
+
+ public void RemoveImage(int name)
{
foreach (NoteImage image in ImageList)
{
- if (image.GetImageLink() == imageLink)
+ if (image.GetName().Equals(name))
+ {
+ ImageList.Remove(image);
+ }
+ else
{
- /// Do something
+ throw new Exception("Image not found");
}
}
}
- public void RemoveImage(string image)
- {
- /// Need a new data structure to store images
- }
-
///
/// vérifier si l'utilisateur est un éditeur de la note
///
diff --git a/notus/Biblioteque_de_Class/NoteImage.cs b/notus/Biblioteque_de_Class/NoteImage.cs
index c141096..1680e74 100644
--- a/notus/Biblioteque_de_Class/NoteImage.cs
+++ b/notus/Biblioteque_de_Class/NoteImage.cs
@@ -8,22 +8,22 @@ namespace Biblioteque_de_Class
{
public class NoteImage
{
- private string Name { get; set; }
+ private int Name { get; set; }
private string ImageLink { get; set; }
private string Position { get; set; }
- public NoteImage(string name, string imageLink, string position)
+ public NoteImage(int name, string imageLink, string position)
{
Name = name;
ImageLink = imageLink;
Position = position;
}
- public string GetName() { return Name; }
+ public int GetName() { return Name; }
public string GetImageLink() { return ImageLink; }
public string GetPosition() { return Position; }
- public void SetName(string name) { Name = name; }
+ public void SetName(int name) { Name = name; }
public void SetImageLink(string imageLink) { ImageLink = imageLink; }
public void SetPosition(string position) { Position = position; }
diff --git a/notus/Notus_Console/Program.cs b/notus/Notus_Console/Program.cs
index ef2afb5..a35b2a4 100644
--- a/notus/Notus_Console/Program.cs
+++ b/notus/Notus_Console/Program.cs
@@ -5,7 +5,7 @@ using System.Diagnostics;
string Upseudo = "u";
string Umail = "u";
string Upassword = "u";
-string nomImag = "u";
+int nomImage = 1;
string linkimage = "u";
string position = "u";
string nomNote = "u";
diff --git a/notus/Notus_UnitTest_Logo/AddCollaboratorTests.cs b/notus/Notus_UnitTest_Logo/AddCollaboratorTests.cs
new file mode 100644
index 0000000..94cdfb7
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/AddCollaboratorTests.cs
@@ -0,0 +1,36 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ public class AddCollaboratorTests
+ {
+ [TestFixture]
+ public class NoteTests
+ {
+ [Test]
+ public void AddCollaborator_WhenUserIsOwner_CollaboratorAdded()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User collaborator = new User("Collaborator1", "collaborator1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddCollaborator(owner, collaborator);
+ Assert.Contains(collaborator, note.GetCollaborators());
+ }
+
+ [Test]
+ public void AddCollaborator_WhenUserIsNotOwner_ThrowsException()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User collaborator = new User("Collaborator1", "collaborator1@example.com", "password");
+ User user = new User("User1", "user1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ Assert.Throws(() => note.AddCollaborator(user, collaborator));
+ }
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/AddEditorTests.cs b/notus/Notus_UnitTest_Logo/AddEditorTests.cs
new file mode 100644
index 0000000..f33ff94
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/AddEditorTests.cs
@@ -0,0 +1,36 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ public class AddEditorTests
+ {
+ [TestFixture]
+ public class NoteTests
+ {
+ [Test]
+ public void AddEditor_WhenUserIsOwner_EditorAdded()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User editor = new User("Editor1", "editor1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddEditor(owner, editor);
+ Assert.IsTrue(note.GetEditors().Contains(editor));
+ }
+
+ [Test]
+ public void AddEditor_WhenUserIsNotOwner_ThrowsException()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User editor = new User("Editor1", "editor1@example.com", "password");
+ User user = new User("User1", "user1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ Assert.Throws(() => note.AddEditor(user, editor));
+ }
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/AddImageTests.cs b/notus/Notus_UnitTest_Logo/AddImageTests.cs
new file mode 100644
index 0000000..746882e
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/AddImageTests.cs
@@ -0,0 +1,23 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ public class AddImageTests
+ {
+ [Test]
+ public void AddImage_WhenImageLinkIsValid_ImageAddedToList()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ string imageLink = "image.png";
+ string position = "top";
+ note.AddImage(imageLink, position);
+ Assert.That(note.GetImageList().Count, Is.EqualTo(1));
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/Notus_UnitTest_Note.csproj b/notus/Notus_UnitTest_Logo/Notus_UnitTest_Note.csproj
new file mode 100644
index 0000000..c83b34c
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/Notus_UnitTest_Note.csproj
@@ -0,0 +1,24 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/notus/Notus_UnitTest_Logo/RemoveCollaboratorTests.cs b/notus/Notus_UnitTest_Logo/RemoveCollaboratorTests.cs
new file mode 100644
index 0000000..09655ab
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/RemoveCollaboratorTests.cs
@@ -0,0 +1,38 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ public class vsdbjksbvd_v
+ {
+ [TestFixture]
+ public class NoteTests
+ {
+ [Test]
+ public void RemoveCollaborator_WhenUserIsOwner_CollaboratorRemoved()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User collaborator = new User("Collaborator1", "collaborator1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddCollaborator(owner, collaborator);
+ note.RemoveCollaborator(owner, collaborator);
+ Assert.IsFalse(note.GetCollaborators().Contains(collaborator));
+ }
+
+ [Test]
+ public void RemoveCollaborator_WhenUserIsNotOwner_ThrowsException()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User collaborator = new User("Collaborator1", "collaborator1@example.com", "password");
+ User user = new User("User1", "user1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddCollaborator(owner, collaborator);
+ Assert.Throws(() => note.RemoveCollaborator(user, collaborator));
+ }
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/RemoveEditorTests.cs b/notus/Notus_UnitTest_Logo/RemoveEditorTests.cs
new file mode 100644
index 0000000..6563c87
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/RemoveEditorTests.cs
@@ -0,0 +1,38 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ public class RemoveEditorTests
+ {
+ [TestFixture]
+ public class NoteTests
+ {
+ [Test]
+ public void RemoveEditor_WhenUserIsOwner_EditorRemoved()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User editor = new User("Editor1", "editor1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddEditor(owner, editor);
+ note.RemoveEditor(owner, editor);
+ Assert.IsFalse(note.GetEditors().Contains(editor));
+ }
+
+ [Test]
+ public void RemoveEditor_WhenUserIsNotOwner_ThrowsException()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ User editor = new User("Editor1", "editor1@example.com", "password");
+ User user = new User("User1", "user1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ note.AddEditor(owner, editor);
+ Assert.Throws(() => note.RemoveEditor(user, editor));
+ }
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/RemoveImageTests.cs b/notus/Notus_UnitTest_Logo/RemoveImageTests.cs
new file mode 100644
index 0000000..82f1d68
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/RemoveImageTests.cs
@@ -0,0 +1,32 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ [TestFixture]
+ public class RemoveImageTests
+ {
+ [Test]
+ public void RemoveImage_WhenImageExists_ImageRemovedFromList()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ NoteImage image = new NoteImage(1, "image.png", "top");
+ note.GetImageList().Add(image);
+ note.RemoveImage(1);
+ Assert.That(note.GetImageList().Count, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void RemoveImage_WhenImageDoesNotExist_ExceptionThrown()
+ {
+ User owner = new User("Owner", "owner@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", owner);
+ Assert.Throws(() => note.RemoveImage(1));
+ }
+ }
+}
diff --git a/notus/Notus_UnitTest_Logo/Usings.cs b/notus/Notus_UnitTest_Logo/Usings.cs
new file mode 100644
index 0000000..cefced4
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/Usings.cs
@@ -0,0 +1 @@
+global using NUnit.Framework;
\ No newline at end of file
diff --git a/notus/Notus_UnitTest_Logo/VerifyOwnerTests.cs b/notus/Notus_UnitTest_Logo/VerifyOwnerTests.cs
new file mode 100644
index 0000000..29e8487
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/VerifyOwnerTests.cs
@@ -0,0 +1,31 @@
+using Biblioteque_de_Class;
+namespace Notus_UnitTest_Note
+{
+ [TestFixture]
+ public class VerifyOwnerTests
+ {
+ [Test]
+ public void VerifyOwner_UserIsOwner_ReturnsTrue()
+ {
+ User owner = new User("John", "john@example.com", "choco");
+ Note note = new Note("My Note", "path/to/logo.png", owner);
+ bool isOwner = note.VerifyOwner(owner);
+ Assert.IsTrue(isOwner);
+ }
+
+ [Test]
+ public void VerifyOwner_UserIsNotOwner_ReturnsFalse()
+ {
+ // Arrange
+ User owner = new User("John", "john@example.com", "choco");
+ User anotherUser = new User("Jane", "jane@example.com", "choco");
+ Note note = new Note("My Note", "path/to/logo.png", owner);
+
+ // Act
+ bool isOwner = note.VerifyOwner(anotherUser);
+
+ // Assert
+ Assert.IsFalse(isOwner);
+ }
+ }
+}
\ No newline at end of file
diff --git a/notus/Notus_UnitTest_Logo/VerifyPrivilegeTests.cs b/notus/Notus_UnitTest_Logo/VerifyPrivilegeTests.cs
new file mode 100644
index 0000000..de10e1b
--- /dev/null
+++ b/notus/Notus_UnitTest_Logo/VerifyPrivilegeTests.cs
@@ -0,0 +1,31 @@
+using Biblioteque_de_Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Notus_UnitTest_Note
+{
+ [TestFixture]
+ public class VerifyPrivilegeTests
+ {
+ [Test]
+ public void VerifyPrivilege_WhenUserIsEditor_ReturnsTrue()
+ {
+ User editor = new User("Editor1", "editor1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", new User("Owner", "owner@example.com", "password"));
+ note.AddEditor(note.GetOwner(), editor);
+ bool result = note.VerifyPrivilege(editor);
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void VerifyPrivilege_WhenUserIsNotEditor_ThrowsException()
+ {
+ User user = new User("User1", "user1@example.com", "password");
+ Note note = new Note("Test Note", "logo.png", new User("Owner", "owner@example.com", "password"));
+ Assert.Throws(() => note.VerifyPrivilege(user));
+ }
+ }
+}
diff --git a/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs b/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs
index 4f57537..40fe94c 100644
--- a/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs
+++ b/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs
@@ -18,19 +18,23 @@ namespace Notus_UnitTest_Database
}
[Test]
- public void GetTheme_ExistingTheme_ReturnsTheme()
+ public void ModifyThemeName_ExistingTheme_ModifiesName()
{
List listcolor = new List() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
database.GetThemeList().Add(theme);
- Theme retrievedTheme = database.GetTheme("Dark");
- Assert.That(retrievedTheme, Is.EqualTo(theme));
+ string newName = "Light";
+ database.ModifyThemeName(theme, newName);
+ Assert.That(theme.GetName(), Is.EqualTo(newName));
}
[Test]
- public void GetTheme_NonExistingTheme_ThrowsException()
+ public void ModifyThemeName_NonExistingTheme_ThrowsException()
{
- Assert.Throws(() => database.GetTheme("NonExistingTheme"), "No theme found with this name.");
+ List listcolor = new List() { "Blue", "Dark", "Grey" };
+ Theme theme = new Theme("ocean", listcolor);
+ string newName = "Light";
+ Assert.Throws(() => database.ModifyThemeName(theme, newName), "Theme not found.");
}
}
}
diff --git a/notus/notus.sln b/notus/notus.sln
index 6c35a63..661806e 100644
--- a/notus/notus.sln
+++ b/notus/notus.sln
@@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_Console", "Notus_Cons
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_Persistance", "Notus_Persistence\Notus_Persistance.csproj", "{184478A9-E14F-42E0-B963-B3A4474C9C1C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notus_UnitTest_Database", "Tests\Notus_UnitTest_Database\Notus_UnitTest_Database.csproj", "{EE443C17-B31D-4AD0-9141-920876E7DF79}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_UnitTest_Database", "Tests\Notus_UnitTest_Database\Notus_UnitTest_Database.csproj", "{EE443C17-B31D-4AD0-9141-920876E7DF79}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notus_UnitTest_Note", "Notus_UnitTest_Logo\Notus_UnitTest_Note.csproj", "{7B7F1062-9498-44E5-AC77-84BC90A3B730}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -41,6 +43,10 @@ Global
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7B7F1062-9498-44E5-AC77-84BC90A3B730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7B7F1062-9498-44E5-AC77-84BC90A3B730}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7B7F1062-9498-44E5-AC77-84BC90A3B730}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7B7F1062-9498-44E5-AC77-84BC90A3B730}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE