diff --git a/API_SQLuedo/TestEF/Mapper/LessonMapperUnitTest.cs b/API_SQLuedo/TestEF/Mapper/LessonMapperUnitTest.cs new file mode 100644 index 0000000..954875c --- /dev/null +++ b/API_SQLuedo/TestEF/Mapper/LessonMapperUnitTest.cs @@ -0,0 +1,47 @@ +using Dto; +using Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Shared.Mapper; +using Model; + +namespace TestEF.Mapper +{ + public class LessonMapperUnitTest + { + private const int _id = 1; + private const string _title = "Title"; + private const string _lastPublisher = "_lastPublisher"; + private DateOnly date = new DateOnly(2024,03,02); + + [Fact] + public void TestDtoToEntity() + { + LessonDTO lesson = new LessonDTO(_id, _title, _lastPublisher, date); + var lessonEntity = lesson.FromDTOToEntity(); + + Assert.NotNull(lessonEntity); + Assert.IsType(lessonEntity); + Assert.Equal(1, lesson.Id); + Assert.Equal(_title, lesson.Title); + Assert.Equal(_lastPublisher, lesson.LastPublisher); + } + + [Fact] + public void TestEntityToDto() + { + LessonEntity lesson = new LessonEntity(_id,_title, _lastPublisher, date); + + var lessonEntity = lesson.FromEntityToDTO(); + + Assert.NotNull(lessonEntity); + Assert.IsType(lessonEntity); + Assert.Equal(1, lesson.Id); + Assert.Equal(_title, lesson.Title); + Assert.Equal(_lastPublisher, lesson.LastPublisher); + } + } +} diff --git a/API_SQLuedo/TestEF/Mapper/ParagraphMapperUnitTest.cs b/API_SQLuedo/TestEF/Mapper/ParagraphMapperUnitTest.cs new file mode 100644 index 0000000..c8f2830 --- /dev/null +++ b/API_SQLuedo/TestEF/Mapper/ParagraphMapperUnitTest.cs @@ -0,0 +1,60 @@ +using Dto; +using Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Shared.Mapper; +using SQLitePCL; + +namespace TestEF.Mapper +{ + public class ParagraphMapperUnitTest + { + + private const int _id = 1; + private const string _title = "Title"; + private const string _content = "Contenu"; + + private const string _info = "Info"; + private const string _query = "Requête"; + private const string _comment = "Comment"; + private const int _lessonId = 2; + + [Fact] + public void TestDtoToEntity() + { + ParagraphDTO paragraph = new ParagraphDTO(_id,_title,_content,_info,_query,_comment,_lessonId); + var paragrahEntity = paragraph.FromDTOToEntity(); + + Assert.NotNull(paragrahEntity); + Assert.IsType(paragrahEntity); + Assert.Equal(1, paragraph.Id); + Assert.Equal(_title, paragraph.Title); + Assert.Equal(_content, paragraph.Content); + Assert.Equal(_info, paragraph.Info); + Assert.Equal(_query, paragraph.Query); + Assert.Equal(_comment, paragraph.Comment); + Assert.Equal(_lessonId, paragraph.LessonId); + + } + + [Fact] + public void TestEntityToDto() + { + ParagraphEntity paragraph = new ParagraphEntity(_id, _title, _content, _info, _query, _comment, _lessonId); + var paragrahEntity = paragraph.FromEntityToDTO(); + + Assert.NotNull(paragrahEntity); + Assert.IsType(paragrahEntity); + Assert.Equal(1, paragraph.Id); + Assert.Equal(_title, paragraph.Title); + Assert.Equal(_content, paragraph.Content); + Assert.Equal(_info, paragraph.Info); + Assert.Equal(_query, paragraph.Query); + Assert.Equal(_comment, paragraph.Comment); + Assert.Equal(_lessonId, paragraph.LessonId); + } + } +}