Test de toutes les classes de Model
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
4ea53b072e
commit
0a2aa5ea92
@ -0,0 +1,32 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class BlackListTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithRightParameters()
|
||||||
|
{
|
||||||
|
BlackList blackList = new BlackList("example@email.com", DateOnly.FromDateTime(DateTime.Now));
|
||||||
|
Assert.Equal("example@email.com", blackList.Email);
|
||||||
|
Assert.Equal(DateOnly.FromDateTime(DateTime.Now), blackList.ExpirationDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithNullEmail()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentException>(() =>
|
||||||
|
{
|
||||||
|
BlackList blackList = new BlackList(null, DateOnly.FromDateTime(DateTime.Now));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithAnteriorDate()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||||
|
{
|
||||||
|
BlackList blackList = new BlackList("example@email.com", DateOnly.FromDateTime(DateTime.Parse("2024/01/01 00:00:00")));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class InquiryTableTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyContructor()
|
||||||
|
{
|
||||||
|
InquiryTable inquiry = new InquiryTable();
|
||||||
|
Assert.Equal(0,inquiry.OwnerId);
|
||||||
|
Assert.Null(inquiry.ConnectionInfo);
|
||||||
|
Assert.Null(inquiry.DatabaseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestFullContructor()
|
||||||
|
{
|
||||||
|
InquiryTable inquiry = new InquiryTable(1,"Database","Connection");
|
||||||
|
Assert.Equal(1,inquiry.OwnerId);
|
||||||
|
Assert.Equal("Connection",inquiry.ConnectionInfo);
|
||||||
|
Assert.Equal("Database",inquiry.DatabaseName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class InquiryTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyContructor()
|
||||||
|
{
|
||||||
|
Inquiry inquiry = new Inquiry();
|
||||||
|
Assert.Equal(0,inquiry.Id);
|
||||||
|
Assert.Null(inquiry.Title);
|
||||||
|
Assert.Null(inquiry.Description);
|
||||||
|
Assert.False(inquiry.IsUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestFullContructor()
|
||||||
|
{
|
||||||
|
Inquiry inquiry = new Inquiry(1,"Title","Description",true);
|
||||||
|
Assert.Equal(1,inquiry.Id);
|
||||||
|
Assert.Equal("Title",inquiry.Title);
|
||||||
|
Assert.Equal("Description",inquiry.Description);
|
||||||
|
Assert.True(inquiry.IsUser);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class LessonTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithoutId()
|
||||||
|
{
|
||||||
|
Lesson lesson = new Lesson("Title", "JohnDoe", DateOnly.FromDateTime(DateTime.Now));
|
||||||
|
Assert.Equal(0, lesson.Id);
|
||||||
|
Assert.Equal("Title", lesson.Title);
|
||||||
|
Assert.Equal("JohnDoe", lesson.LastPublisher);
|
||||||
|
Assert.Equal(DateOnly.FromDateTime(DateTime.Now), lesson.LastEdit);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithId()
|
||||||
|
{
|
||||||
|
Lesson lesson = new Lesson(42,"Title", "JohnDoe", DateOnly.FromDateTime(DateTime.Now));
|
||||||
|
Assert.Equal(42, lesson.Id);
|
||||||
|
Assert.Equal("Title", lesson.Title);
|
||||||
|
Assert.Equal("JohnDoe", lesson.LastPublisher);
|
||||||
|
Assert.Equal(DateOnly.FromDateTime(DateTime.Now), lesson.LastEdit);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class NotepadTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyConstructor()
|
||||||
|
{
|
||||||
|
Notepad notepad = new Notepad();
|
||||||
|
Assert.Equal(0, notepad.Id);
|
||||||
|
Assert.Equal(0, notepad.UserId);
|
||||||
|
Assert.Equal(0, notepad.InquiryId);
|
||||||
|
Assert.Null(notepad.Notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithoutId()
|
||||||
|
{
|
||||||
|
Notepad notepad = new Notepad(42,42,"Notes");
|
||||||
|
Assert.Equal(0, notepad.Id);
|
||||||
|
Assert.Equal(42, notepad.UserId);
|
||||||
|
Assert.Equal(42, notepad.InquiryId);
|
||||||
|
Assert.Equal("Notes",notepad.Notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithId()
|
||||||
|
{
|
||||||
|
Notepad notepad = new Notepad(42,42,42,"Notes");
|
||||||
|
Assert.Equal(42, notepad.Id);
|
||||||
|
Assert.Equal(42, notepad.UserId);
|
||||||
|
Assert.Equal(42, notepad.InquiryId);
|
||||||
|
Assert.Equal("Notes",notepad.Notes);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class ParagraphTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithoutId()
|
||||||
|
{
|
||||||
|
Paragraph paragraph = new Paragraph("Title", "Content","Info","Query","Comment");
|
||||||
|
Assert.Equal(0, paragraph.Id);
|
||||||
|
Assert.Equal(0, paragraph.LessonId);
|
||||||
|
Assert.Equal("Title", paragraph.ContentTitle);
|
||||||
|
Assert.Equal("Content", paragraph.ContentContent);
|
||||||
|
Assert.Equal("Info", paragraph.Info);
|
||||||
|
Assert.Equal("Query", paragraph.Query);
|
||||||
|
Assert.Equal("Comment", paragraph.Comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithId()
|
||||||
|
{
|
||||||
|
Paragraph paragraph = new Paragraph(42,"Title", "Content","Info","Query","Comment",42);
|
||||||
|
Assert.Equal(42, paragraph.Id);
|
||||||
|
Assert.Equal(42, paragraph.LessonId);
|
||||||
|
Assert.Equal("Title", paragraph.ContentTitle);
|
||||||
|
Assert.Equal("Content", paragraph.ContentContent);
|
||||||
|
Assert.Equal("Info", paragraph.Info);
|
||||||
|
Assert.Equal("Query", paragraph.Query);
|
||||||
|
Assert.Equal("Comment", paragraph.Comment);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class SolutionTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyConstructor()
|
||||||
|
{
|
||||||
|
Solution solution = new Solution();
|
||||||
|
Assert.Equal(0,solution.OwnerId);
|
||||||
|
Assert.Null(solution.MurdererFirstName);
|
||||||
|
Assert.Null(solution.MurdererLastName);
|
||||||
|
Assert.Null(solution.MurderPlace);
|
||||||
|
Assert.Null(solution.MurderWeapon);
|
||||||
|
Assert.Null(solution.Explaination);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithoutId()
|
||||||
|
{
|
||||||
|
Solution solution = new Solution("John","Doe","Bedroom","Knife","Because");
|
||||||
|
Assert.Equal(0,solution.OwnerId);
|
||||||
|
Assert.Equal("John",solution.MurdererFirstName);
|
||||||
|
Assert.Equal("Doe",solution.MurdererLastName);
|
||||||
|
Assert.Equal("Bedroom",solution.MurderPlace);
|
||||||
|
Assert.Equal("Knife",solution.MurderWeapon);
|
||||||
|
Assert.Equal("Because",solution.Explaination);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestConstructorWithId()
|
||||||
|
{
|
||||||
|
Solution solution = new Solution(42,"John","Doe","Bedroom","Knife","Because");
|
||||||
|
Assert.Equal(42,solution.OwnerId);
|
||||||
|
Assert.Equal("John",solution.MurdererFirstName);
|
||||||
|
Assert.Equal("Doe",solution.MurdererLastName);
|
||||||
|
Assert.Equal("Bedroom",solution.MurderPlace);
|
||||||
|
Assert.Equal("Knife",solution.MurderWeapon);
|
||||||
|
Assert.Equal("Because",solution.Explaination);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class SuccessTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyConstructor()
|
||||||
|
{
|
||||||
|
Success success = new Success();
|
||||||
|
Assert.Equal(0,success.UserId);
|
||||||
|
Assert.Equal(0,success.InquiryId);
|
||||||
|
Assert.False(success.IsFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestFullConstructor()
|
||||||
|
{
|
||||||
|
Success success = new Success(42,42,true);
|
||||||
|
Assert.Equal(42,success.UserId);
|
||||||
|
Assert.Equal(42,success.InquiryId);
|
||||||
|
Assert.True(success.IsFinished);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace TestEF.Model;
|
||||||
|
|
||||||
|
public class UserTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
void TestEmptyConstructor()
|
||||||
|
{
|
||||||
|
User user = new User();
|
||||||
|
Assert.Equal(0,user.Id);
|
||||||
|
Assert.Null(user.Username);
|
||||||
|
Assert.Null(user.Email);
|
||||||
|
Assert.Null(user.Password);
|
||||||
|
Assert.False(user.IsAdmin);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
void TestFullConstructor()
|
||||||
|
{
|
||||||
|
User user = new User(42,"Username","Password","Email",true);
|
||||||
|
Assert.Equal(42,user.Id);
|
||||||
|
Assert.Equal("Username",user.Username);
|
||||||
|
Assert.Equal("Email",user.Email);
|
||||||
|
Assert.Equal("Password",user.Password);
|
||||||
|
Assert.True(user.IsAdmin);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue