diff --git a/notus/Biblioteque_de_Class/Database.cs b/notus/Biblioteque_de_Class/Database.cs index d094647..840d946 100644 --- a/notus/Biblioteque_de_Class/Database.cs +++ b/notus/Biblioteque_de_Class/Database.cs @@ -53,7 +53,7 @@ namespace Biblioteque_de_Class { if (logo.GetName() == name) { return logo.GetLogoLink(); } } - throw new LogoNotFoundException("No logo link found."); + throw new NotFoundException("No logo link found."); } /// @@ -68,7 +68,7 @@ namespace Biblioteque_de_Class return user; } } - throw new UserAlreadyUsedException("No user found with this username."); + throw new AlreadyUsedException("No user found with this username."); } /// @@ -103,11 +103,11 @@ namespace Biblioteque_de_Class { if (existingUser.GetUsername() == user.GetUsername()) { - throw new UserAlreadyUsedException("Username already used."); + throw new AlreadyUsedException("Username already used."); } else if (existingUser.GetEmail() == user.GetEmail()) { - throw new UserAlreadyUsedException("Email already used."); + throw new AlreadyUsedException("Email already used."); } } UserList.Add(user); @@ -124,7 +124,7 @@ namespace Biblioteque_de_Class } else { - throw new UserNotFoundException("User not found."); + throw new NotFoundException("User not found."); } } @@ -137,7 +137,7 @@ namespace Biblioteque_de_Class { if (existingTheme.GetName() == theme.GetName()) { - throw new ThemeAlreadyUsedException("Theme already used."); + throw new AlreadyUsedException("Theme already used."); } } ThemeList.Add(theme); @@ -154,7 +154,7 @@ namespace Biblioteque_de_Class } else { - throw new ThemeNotFoundException("Theme not found."); + throw new NotFoundException("Theme not found."); } } @@ -170,7 +170,7 @@ namespace Biblioteque_de_Class return theme; } } - throw new ThemeNotFoundException("No theme found with this name."); + throw new NotFoundException("No theme found with this name."); } /// @@ -186,7 +186,7 @@ namespace Biblioteque_de_Class return; } } - throw new ThemeNotFoundException("Theme not found."); + throw new NotFoundException("Theme not found."); } /// @@ -205,7 +205,7 @@ namespace Biblioteque_de_Class return; } } - throw new ThemeNotFoundException("Theme not found."); + throw new NotFoundException("Theme not found."); } } } \ No newline at end of file diff --git a/notus/Biblioteque_de_Class/Exception.cs b/notus/Biblioteque_de_Class/Exception.cs index 365774e..b37c3e4 100644 --- a/notus/Biblioteque_de_Class/Exception.cs +++ b/notus/Biblioteque_de_Class/Exception.cs @@ -6,51 +6,27 @@ using System.Threading.Tasks; namespace Biblioteque_de_Class { - public class LogoNotFoundException : Exception + public class NotAllowedException : Exception { - public LogoNotFoundException(string message) : base(message) + public NotAllowedException(string message) : base(message) { } } - public class UserNotFoundException : Exception + public class AlreadyUsedException : Exception { - public UserNotFoundException(string message) : base(message) + public AlreadyUsedException(string message) : base(message) { } } - public class UserAlreadyUsedException : Exception + public class NotFoundException : Exception { - public UserAlreadyUsedException(string message) : base(message) + public NotFoundException(string message) : base(message) { } } - public class UserNotOwnerException : Exception + public class AlreadyExistException : Exception { - public UserNotOwnerException(string message) : base(message) - { - } - } - public class UserNotEditorException : Exception - { - public UserNotEditorException(string message) : base(message) - { - } - } - public class ThemeNotFoundException : Exception - { - public ThemeNotFoundException(string message) : base(message) - { - } - } - public class ThemeAlreadyUsedException : Exception - { - public ThemeAlreadyUsedException(string message) : base(message) - { - } - } - public class NoteImageNotFoundException : Exception - { - public NoteImageNotFoundException(string message) : base(message) + public AlreadyExistException(string message) : base(message) { } } diff --git a/notus/Biblioteque_de_Class/Note.cs b/notus/Biblioteque_de_Class/Note.cs index 99dc6b3..2d072e1 100644 --- a/notus/Biblioteque_de_Class/Note.cs +++ b/notus/Biblioteque_de_Class/Note.cs @@ -84,7 +84,7 @@ namespace Biblioteque_de_Class return; } } - throw new NoteImageNotFoundException("Image not found"); + throw new NotFoundException("Image not found"); } /// @@ -101,7 +101,7 @@ namespace Biblioteque_de_Class public void AddCollaborator(User owner, User user) { if (VerifyOwner(owner)) { Collaborators.Add(user); } - else { throw new UserNotOwnerException("User is not the owner"); } + else { throw new NotAllowedException("User is not the owner"); } } /// @@ -110,7 +110,7 @@ namespace Biblioteque_de_Class public void RemoveCollaborator(User owner, User user) { if (VerifyOwner(owner)) { Collaborators.Remove(user); } - else { throw new UserNotOwnerException("User is not the owner"); } + else { throw new NotAllowedException("User is not the owner"); } } /// @@ -119,7 +119,7 @@ namespace Biblioteque_de_Class public void AddEditor(User owner, User user) { if (VerifyOwner(owner)) { Editors.Add(user); } - else { throw new UserNotOwnerException("User is not the owner"); } + else { throw new NotAllowedException("User is not the owner"); } } /// @@ -128,7 +128,7 @@ namespace Biblioteque_de_Class public void RemoveEditor(User owner, User user) { if (VerifyOwner(owner)) { Editors.Remove(user); } - else { throw new UserNotOwnerException("User is not the owner"); } + else { throw new NotAllowedException("User is not the owner"); } } } } diff --git a/notus/Biblioteque_de_Class/User.cs b/notus/Biblioteque_de_Class/User.cs index a5857e4..86c3168 100644 --- a/notus/Biblioteque_de_Class/User.cs +++ b/notus/Biblioteque_de_Class/User.cs @@ -110,7 +110,7 @@ namespace Biblioteque_de_Class { if (FavList.Contains(note)) { - throw new Exception("Note already in favorites"); + throw new AlreadyExistException("Note already in favorites"); } FavList.Add(note); } @@ -126,7 +126,7 @@ namespace Biblioteque_de_Class } else { - throw new NullReferenceException("Note not found"); + throw new NotFoundException("Note not found"); } } @@ -139,7 +139,7 @@ namespace Biblioteque_de_Class { if (existingNote.GetName() == name) { - throw new Exception("Note already exists"); + throw new AlreadyExistException("Note already exists"); } } Note note = new Note(name, imagePath, this); @@ -159,7 +159,7 @@ namespace Biblioteque_de_Class } else { - throw new NullReferenceException("Note not found"); + throw new NotFoundException("Note not found"); } } @@ -172,7 +172,7 @@ namespace Biblioteque_de_Class { if (tag.GetName() == name) { - throw new Exception("Tag already exists"); + throw new AlreadyExistException("Tag already exists"); } } TagList.Add(new Tags(name, color)); @@ -200,11 +200,11 @@ namespace Biblioteque_de_Class { if (!TagList.Contains(tagToAdd)) { - throw new Exception("Tag not found"); + throw new NotFoundException("Tag not found"); } if (!NoteList.Contains(note)) { - throw new Exception("Note not found"); + throw new NotFoundException("Note not found"); } NoteTagged[note].Add(tagToAdd); } @@ -216,11 +216,11 @@ namespace Biblioteque_de_Class { if (!TagList.Contains(tagToRemove)) { - throw new Exception("Tag not found"); + throw new NotFoundException("Tag not found"); } if (!NoteList.Contains(note)) { - throw new Exception("Note not found"); + throw new NotFoundException("Note not found"); } NoteTagged[note].Remove(tagToRemove); } diff --git a/notus/Tests/Notus_UnitTest_Database/AddThemeTests.cs b/notus/Tests/Notus_UnitTest_Database/AddThemeTests.cs index 3ca9bfc..6e0990f 100644 --- a/notus/Tests/Notus_UnitTest_Database/AddThemeTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/AddThemeTests.cs @@ -33,7 +33,7 @@ namespace Notus_UnitTest_Database List listcolor = new(); Theme theme = new Theme("ocean", listcolor); database.AddTheme(theme); - Assert.Throws(() => database.AddTheme(theme), "Theme already used."); + Assert.Throws(() => database.AddTheme(theme), "Theme already used."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/AddUserTests.cs b/notus/Tests/Notus_UnitTest_Database/AddUserTests.cs index d2ebe67..26312b5 100644 --- a/notus/Tests/Notus_UnitTest_Database/AddUserTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/AddUserTests.cs @@ -34,7 +34,7 @@ namespace Notus_UnitTest_Database database.GetUserList().Add(existingUser); User newUser = new User("John1", "rien", "choco"); newUser.SetEmail("Jane@example.com"); - Assert.Throws(() => database.AddUser(newUser), "Username already used."); + Assert.Throws(() => database.AddUser(newUser), "Username already used."); } [Test] @@ -45,7 +45,7 @@ namespace Notus_UnitTest_Database database.GetUserList().Add(existingUser); User newUser = new User("Jane", "rien", "choco"); newUser.SetEmail("john2@example.com"); - Assert.Throws(() => database.AddUser(newUser), "Email already used."); + Assert.Throws(() => database.AddUser(newUser), "Email already used."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/GetLogoLinkTests.cs b/notus/Tests/Notus_UnitTest_Database/GetLogoLinkTests.cs index 4b996f9..c4d1d5a 100644 --- a/notus/Tests/Notus_UnitTest_Database/GetLogoLinkTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/GetLogoLinkTests.cs @@ -28,7 +28,7 @@ namespace Notus_UnitTest_Database public void GetLogoLink_LogoDoesNotExist_ThrowsException() { string logoName = "Logo4"; - Assert.Throws(() => database.GetLogoLink(logoName)); + Assert.Throws(() => database.GetLogoLink(logoName)); } } } \ No newline at end of file diff --git a/notus/Tests/Notus_UnitTest_Database/GetThemeTests.cs b/notus/Tests/Notus_UnitTest_Database/GetThemeTests.cs index b71a58f..5f857f9 100644 --- a/notus/Tests/Notus_UnitTest_Database/GetThemeTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/GetThemeTests.cs @@ -30,7 +30,7 @@ namespace Notus_UnitTest_Database [Test] public void GetTheme_NonExistingTheme_ThrowsException() { - Assert.Throws(() => database.GetTheme("NonExistingTheme"), "No theme found with this name."); + Assert.Throws(() => database.GetTheme("NonExistingTheme"), "No theme found with this name."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/GetUserTests.cs b/notus/Tests/Notus_UnitTest_Database/GetUserTests.cs index 0515de8..cb17df4 100644 --- a/notus/Tests/Notus_UnitTest_Database/GetUserTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/GetUserTests.cs @@ -30,7 +30,7 @@ namespace Notus_UnitTest_Database public void GetUser_UserDoesNotExist_ThrowsException() { string userName = "Eve"; - Assert.Throws(() => database.GetUser(userName)); + Assert.Throws(() => database.GetUser(userName)); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/ModifyThemeColorListTests.cs b/notus/Tests/Notus_UnitTest_Database/ModifyThemeColorListTests.cs index e839ba7..a75f241 100644 --- a/notus/Tests/Notus_UnitTest_Database/ModifyThemeColorListTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/ModifyThemeColorListTests.cs @@ -37,7 +37,7 @@ namespace Notus_UnitTest_Database Theme theme = new Theme("ocean", listcolor); // no add :) List newColorList = new List { "Red", "Green", "Blue" }; - Assert.Throws(() => database.ModifyThemeColorList(theme, newColorList), "Theme not found."); + Assert.Throws(() => database.ModifyThemeColorList(theme, newColorList), "Theme not found."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs b/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs index 66d015b..d22f5ac 100644 --- a/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/ModifyThemeNameTests.cs @@ -34,7 +34,7 @@ namespace Notus_UnitTest_Database 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."); + Assert.Throws(() => database.ModifyThemeName(theme, newName), "Theme not found."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/RemoveThemeTests.cs b/notus/Tests/Notus_UnitTest_Database/RemoveThemeTests.cs index 56a3510..ef16204 100644 --- a/notus/Tests/Notus_UnitTest_Database/RemoveThemeTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/RemoveThemeTests.cs @@ -32,7 +32,7 @@ namespace Notus_UnitTest_Database { List listcolor = new(); Theme theme = new Theme("ocean", listcolor); - Assert.Throws(() => database.RemoveTheme(theme), "Theme already used."); + Assert.Throws(() => database.RemoveTheme(theme), "Theme already used."); } } } diff --git a/notus/Tests/Notus_UnitTest_Database/RemoveUserTests.cs b/notus/Tests/Notus_UnitTest_Database/RemoveUserTests.cs index 361072d..4a731c9 100644 --- a/notus/Tests/Notus_UnitTest_Database/RemoveUserTests.cs +++ b/notus/Tests/Notus_UnitTest_Database/RemoveUserTests.cs @@ -32,7 +32,7 @@ namespace Notus_UnitTest_Database { User user = new User("John", "rien", "choco"); user.SetEmail("john@example.com"); - Assert.Throws(() => database.RemoveUser(user), "User not found."); + Assert.Throws(() => database.RemoveUser(user), "User not found."); } } } diff --git a/notus/Tests/Notus_UnitTest_Note/AddCollaboratorTests.cs b/notus/Tests/Notus_UnitTest_Note/AddCollaboratorTests.cs index 085f360..0116c1d 100644 --- a/notus/Tests/Notus_UnitTest_Note/AddCollaboratorTests.cs +++ b/notus/Tests/Notus_UnitTest_Note/AddCollaboratorTests.cs @@ -22,7 +22,7 @@ namespace Notus_UnitTest_Note 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)); + Assert.Throws(() => note.AddCollaborator(user, collaborator)); } } } diff --git a/notus/Tests/Notus_UnitTest_Note/AddEditorTests.cs b/notus/Tests/Notus_UnitTest_Note/AddEditorTests.cs index 7fa8423..d6e420a 100644 --- a/notus/Tests/Notus_UnitTest_Note/AddEditorTests.cs +++ b/notus/Tests/Notus_UnitTest_Note/AddEditorTests.cs @@ -22,7 +22,7 @@ namespace Notus_UnitTest_Note 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)); + Assert.Throws(() => note.AddEditor(user, editor)); } } diff --git a/notus/Tests/Notus_UnitTest_Note/RemoveCollaboratorTests.cs b/notus/Tests/Notus_UnitTest_Note/RemoveCollaboratorTests.cs index b49b9e5..daa888f 100644 --- a/notus/Tests/Notus_UnitTest_Note/RemoveCollaboratorTests.cs +++ b/notus/Tests/Notus_UnitTest_Note/RemoveCollaboratorTests.cs @@ -29,7 +29,7 @@ namespace Notus_UnitTest_Note 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)); + Assert.Throws(() => note.RemoveCollaborator(user, collaborator)); } } diff --git a/notus/Tests/Notus_UnitTest_Note/RemoveEditorTests.cs b/notus/Tests/Notus_UnitTest_Note/RemoveEditorTests.cs index 37b5de2..90b1251 100644 --- a/notus/Tests/Notus_UnitTest_Note/RemoveEditorTests.cs +++ b/notus/Tests/Notus_UnitTest_Note/RemoveEditorTests.cs @@ -29,7 +29,7 @@ namespace Notus_UnitTest_Note 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)); + Assert.Throws(() => note.RemoveEditor(user, editor)); } } diff --git a/notus/Tests/Notus_UnitTest_Note/RemoveImageTests.cs b/notus/Tests/Notus_UnitTest_Note/RemoveImageTests.cs index af9502b..f4143d1 100644 --- a/notus/Tests/Notus_UnitTest_Note/RemoveImageTests.cs +++ b/notus/Tests/Notus_UnitTest_Note/RemoveImageTests.cs @@ -25,7 +25,7 @@ namespace Notus_UnitTest_Note { User owner = new User("Owner", "owner@example.com", "password"); Note note = new Note("Test Note", "logo.png", owner); - Assert.Throws(() => note.RemoveImage(1)); + Assert.Throws(() => note.RemoveImage(1)); } } }