From 534589dbdf5de9d5543d107238de7c7d42178e72 Mon Sep 17 00:00:00 2001 From: Erwan MENAGER Date: Fri, 15 Mar 2024 17:19:58 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20des=20TU=20pour=20les=20D?= =?UTF-8?q?TO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/TestEF/Dto/TestInquiryDTO.cs | 41 +++++++++++++++ API_SQLuedo/TestEF/Dto/TestInquiryTableDTO.cs | 28 +++++++++++ API_SQLuedo/TestEF/Dto/TestLessonDTO.cs | 41 +++++++++++++++ API_SQLuedo/TestEF/Dto/TestNotepadDTO.cs | 41 +++++++++++++++ API_SQLuedo/TestEF/Dto/TestParagraphDTO.cs | 50 +++++++++++++++++++ API_SQLuedo/TestEF/Dto/TestSolutionDTO.cs | 48 ++++++++++++++++++ API_SQLuedo/TestEF/Dto/TestSuccessDTO.cs | 28 +++++++++++ API_SQLuedo/TestEF/Dto/TestUserDTO.cs | 46 +++++++++++++++++ 8 files changed, 323 insertions(+) create mode 100644 API_SQLuedo/TestEF/Dto/TestInquiryDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestInquiryTableDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestLessonDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestNotepadDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestParagraphDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestSolutionDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestSuccessDTO.cs create mode 100644 API_SQLuedo/TestEF/Dto/TestUserDTO.cs diff --git a/API_SQLuedo/TestEF/Dto/TestInquiryDTO.cs b/API_SQLuedo/TestEF/Dto/TestInquiryDTO.cs new file mode 100644 index 0000000..966c29f --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestInquiryDTO.cs @@ -0,0 +1,41 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestInquiryDTO +{ + private const int _id = 1; + private const string _title = "Title"; + private const string _description = "_description"; + private const bool _isUser = true; + + [Fact] + public void TestConstructorWithId() + { + InquiryDTO inquiry = new InquiryDTO(_id, _title, _description, _isUser); + Assert.Equal(_id, inquiry.Id); + Assert.Equal(_title, inquiry.Title); + Assert.Equal(_description, inquiry.Description); + Assert.True(inquiry.IsUser); + } + + [Fact] + public void TestConstructorWithoutId() + { + InquiryDTO inquiry = new InquiryDTO(_title,_description,_isUser); + Assert.Equal(0, inquiry.Id); + Assert.Equal(_title,inquiry.Title); + Assert.Equal(_description,inquiry.Description); + Assert.True(inquiry.IsUser); + } + + [Fact] + public void TestConstructorWithAllAttributes() + { + InquiryDTO inquiry = new InquiryDTO(_id,_title,_description,_isUser); + Assert.Equal(_id, inquiry.Id); + Assert.Equal(_title,inquiry.Title); + Assert.Equal(_description,inquiry.Description); + Assert.True(inquiry.IsUser); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestInquiryTableDTO.cs b/API_SQLuedo/TestEF/Dto/TestInquiryTableDTO.cs new file mode 100644 index 0000000..93be409 --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestInquiryTableDTO.cs @@ -0,0 +1,28 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestInquiryTableDTO +{ + private const int _id = 1; + private const string _database = "database"; + private const string _connection = "_connection"; + + [Fact] + public void TestConstructorWithId() + { + InquiryTableDTO inquiry = new InquiryTableDTO(_id, _database, _connection); + Assert.Equal(_id, inquiry.OwnerId); + Assert.Equal(_database, inquiry.DatabaseName); + Assert.Equal(_connection, inquiry.ConnectionInfo); + } + + [Fact] + public void TestDefaultConstructor() + { + InquiryTableDTO inquiry = new InquiryTableDTO(); + Assert.Equal(0, inquiry.OwnerId); + Assert.Null(inquiry.DatabaseName); + Assert.Null(inquiry.ConnectionInfo); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestLessonDTO.cs b/API_SQLuedo/TestEF/Dto/TestLessonDTO.cs new file mode 100644 index 0000000..ec46211 --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestLessonDTO.cs @@ -0,0 +1,41 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestLessonDTO +{ + private const int _id = 42; + private const string _title = "Title"; + private const string _lastPublisher = "Last Publisher"; + private static DateOnly _lastEdit = new DateOnly(); + + [Fact] + public void TestDefaultConstructor() + { + LessonDTO lesson = new LessonDTO(); + Assert.Equal(0, lesson.Id); + Assert.Null(lesson.Title); + Assert.Null(lesson.LastPublisher); + Assert.Null(lesson.LastEdit); + } + + [Fact] + public void TestConstructorWithoutId() + { + LessonDTO lesson = new LessonDTO(_title,_lastPublisher,_lastEdit); + Assert.Equal(0, lesson.Id); + Assert.Equal(_title,lesson.Title); + Assert.Equal(_lastPublisher,lesson.LastPublisher); + Assert.Equal(_lastEdit,lesson.LastEdit); + } + + [Fact] + public void TestConstructorWithAllAttributes() + { + LessonDTO lesson = new LessonDTO(_id,_title,_lastPublisher,_lastEdit); + Assert.Equal(_id, lesson.Id); + Assert.Equal(_title,lesson.Title); + Assert.Equal(_lastPublisher,lesson.LastPublisher); + Assert.Equal(_lastEdit,lesson.LastEdit); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestNotepadDTO.cs b/API_SQLuedo/TestEF/Dto/TestNotepadDTO.cs new file mode 100644 index 0000000..ad76d8a --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestNotepadDTO.cs @@ -0,0 +1,41 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestNotepadDTO +{ + private const int _id = 42; + private const int _userId = 42; + private const int _inquiryId = 42; + private const string _notes = "This is some notes example"; + + [Fact] + public void TestDefaultConstructor() + { + NotepadDTO notepad = new NotepadDTO(); + Assert.Equal(0,notepad.Id); + Assert.Equal(0,notepad.UserId); + Assert.Equal(0,notepad.InquiryId); + Assert.Null(notepad.Notes); + } + + [Fact] + public void TestConstructorWithoutId() + { + NotepadDTO notepad = new NotepadDTO(_userId,_inquiryId,_notes); + Assert.Equal(0,notepad.Id); + Assert.Equal(_userId,notepad.UserId); + Assert.Equal(_inquiryId,notepad.InquiryId); + Assert.Equal(_notes,notepad.Notes); + } + + [Fact] + public void TestConstructorWithAllAttributes() + { + NotepadDTO notepad = new NotepadDTO(_id,_userId,_inquiryId,_notes); + Assert.Equal(_id,notepad.Id); + Assert.Equal(_userId,notepad.UserId); + Assert.Equal(_inquiryId,notepad.InquiryId); + Assert.Equal(_notes,notepad.Notes); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestParagraphDTO.cs b/API_SQLuedo/TestEF/Dto/TestParagraphDTO.cs new file mode 100644 index 0000000..95dee02 --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestParagraphDTO.cs @@ -0,0 +1,50 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestParagraphDTO +{ + private const int _id = 42; + private const string _title = "Title"; + private const string _info = "Info"; + private const string _content = "Content"; + private const string _query = "Query"; + private const string _comment = "Comment"; + + [Fact] + public void TestDefaultConstructor() + { + ParagraphDTO paragraph = new ParagraphDTO(); + Assert.Equal(0, paragraph.Id); + Assert.Null(paragraph.Title); + Assert.Null(paragraph.Info); + Assert.Null(paragraph.Content); + Assert.Null(paragraph.Query); + Assert.Null(paragraph.Comment); + } + + [Fact] + public void TestConstructorWithoutId() + { + ParagraphDTO paragraph = new ParagraphDTO(_title,_content,_info,_query,_comment, 10); + Assert.Equal(0, paragraph.Id); + Assert.Equal(_title,paragraph.Title); + Assert.Equal(_info,paragraph.Info); + Assert.Equal(_content,paragraph.Content); + Assert.Equal(_query,paragraph.Query); + Assert.Equal(_comment,paragraph.Comment); + } + + [Fact] + public void TestConstructorWithAllAttributes() + { + ParagraphDTO paragraph = new ParagraphDTO(_id,_title,_content,_info,_query,_comment,10); + Assert.Equal(_id, paragraph.Id); + Assert.Equal(_title,paragraph.Title); + Assert.Equal(_info,paragraph.Info); + Assert.Equal(_content,paragraph.Content); + Assert.Equal(_query,paragraph.Query); + Assert.Equal(_comment,paragraph.Comment); + Assert.Equal(10, paragraph.LessonId); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestSolutionDTO.cs b/API_SQLuedo/TestEF/Dto/TestSolutionDTO.cs new file mode 100644 index 0000000..7a137b2 --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestSolutionDTO.cs @@ -0,0 +1,48 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestSolutionDTO +{ + private const string _murdererFirstName = "John"; + private const string _murdererLastName = "Doe"; + private const string _murderPlace = "WhiteHouse"; + private const string _murderWeapon = "Nuclear Bomb"; + private const string _explaination = "This is an explaination"; + private const int _inquiryId = 42; + + [Fact] + public void TestDefaultConstructor() + { + SolutionDTO solution = new SolutionDTO(); + Assert.Equal(0,solution.OwnerId); + Assert.Null(solution.MurdererFirstName); + Assert.Null(solution.MurdererLastName); + Assert.Null(solution.MurderPlace); + Assert.Null(solution.MurderWeapon); + Assert.Null(solution.Explanation); + } + [Fact] + public void TestConstructorWithoutOwnerId() + { + SolutionDTO solution = new SolutionDTO(_murdererFirstName,_murdererLastName,_murderPlace,_murderWeapon, _explaination); + Assert.Equal(0,solution.OwnerId); + Assert.Equal(_murdererFirstName,solution.MurdererFirstName); + Assert.Equal(_murdererLastName,solution.MurdererLastName); + Assert.Equal(_murderPlace,solution.MurderPlace); + Assert.Equal(_murderWeapon,solution.MurderWeapon); + Assert.Equal(_explaination, solution.Explanation); + } + + [Fact] + public void TestConstructorWithAllAttributes() + { + SolutionDTO solution = new SolutionDTO(_inquiryId,_murdererFirstName,_murdererLastName,_murderPlace,_murderWeapon, _explaination); + Assert.Equal(_inquiryId,solution.OwnerId); + Assert.Equal(_murdererFirstName,solution.MurdererFirstName); + Assert.Equal(_murdererLastName,solution.MurdererLastName); + Assert.Equal(_murderPlace,solution.MurderPlace); + Assert.Equal(_murderWeapon,solution.MurderWeapon); + Assert.Equal(_explaination, solution.Explanation); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestSuccessDTO.cs b/API_SQLuedo/TestEF/Dto/TestSuccessDTO.cs new file mode 100644 index 0000000..097e35d --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestSuccessDTO.cs @@ -0,0 +1,28 @@ +using Dto; + +namespace TestEF.Dto; + +public class TestSuccessDTO +{ + private const int _userId = 42; + private const int _inquiryId = 7; + private const bool _isFinished = true; + + [Fact] + public void TestDefaultConstructor() + { + SuccessDTO success = new SuccessDTO(); + Assert.Equal(0, success.UserId); + Assert.Equal(0, success.InquiryId); + Assert.False(success.IsFinished); + } + + [Fact] + public void TestConstructorWithIds() + { + SuccessDTO success = new SuccessDTO(_userId, _inquiryId, _isFinished); + Assert.Equal(_userId, success.UserId); + Assert.Equal(_inquiryId, success.InquiryId); + Assert.True(success.IsFinished); + } +} \ No newline at end of file diff --git a/API_SQLuedo/TestEF/Dto/TestUserDTO.cs b/API_SQLuedo/TestEF/Dto/TestUserDTO.cs new file mode 100644 index 0000000..b1e68ca --- /dev/null +++ b/API_SQLuedo/TestEF/Dto/TestUserDTO.cs @@ -0,0 +1,46 @@ +using Dto; + +namespace TestEF.Dto +{ + public class TestUserDTO + { + private const string _username = "username"; + private const string _email = "example@email.com"; + private const string _password = "password"; + private const bool _isAdmin = true; + private const int _id = 42; + + [Fact] + public void TestDefaultConstructor() + { + UserDTO user = new UserDTO(); + Assert.Equal(0,user.Id); + Assert.Null(user.Username); + Assert.Null(user.Email); + Assert.Null(user.Password); + Assert.False(user.IsAdmin); + } + + [Fact] + public void TestConstructorWithoutId() + { + UserDTO user = new UserDTO(_username, _password, _email, _isAdmin); + Assert.Equal(0,user.Id); + Assert.Equal(_username, user.Username); + Assert.Equal(_email, user.Email); + Assert.Equal(_password, user.Password); + Assert.True(user.IsAdmin); + } + + [Fact] + public void TestConstructorWithoutAllAttributes() + { + UserDTO user = new UserDTO(_id, _username, _password, _email, _isAdmin); + Assert.Equal(_id,user.Id); + Assert.Equal(_username, user.Username); + Assert.Equal(_email, user.Email); + Assert.Equal(_password, user.Password); + Assert.True(user.IsAdmin); + } + } +} \ No newline at end of file