parent
99471a3705
commit
c4dd76334d
@ -1,49 +1,64 @@
|
||||
using Entities;
|
||||
|
||||
namespace TestEF;
|
||||
namespace TestEF.EntitiesTests;
|
||||
|
||||
public class TestNotepadEntity
|
||||
{
|
||||
private const int _id = 42;
|
||||
private const int _userId = 42;
|
||||
private static UserEntity _userEntity = new UserEntity();
|
||||
private const int _inquiryId = 42;
|
||||
private static InquiryEntity _inquiryEntity = new InquiryEntity();
|
||||
private const string _notes = "This is some notes example";
|
||||
private const int Id = 42;
|
||||
private const int UserId = 42;
|
||||
private static readonly UserEntity UserEntity = new();
|
||||
private const int InquiryId = 42;
|
||||
private static readonly InquiryEntity InquiryEntity = new();
|
||||
private const string Notes = "This is some notes example";
|
||||
|
||||
[Fact]
|
||||
public void TestDefaultConstructor()
|
||||
{
|
||||
NotepadEntity notepad = new NotepadEntity();
|
||||
Assert.Equal(0,notepad.Id);
|
||||
Assert.Equal(0,notepad.UserId);
|
||||
Assert.Equal(0, notepad.Id);
|
||||
Assert.Equal(0, notepad.UserId);
|
||||
Assert.Null(notepad.User);
|
||||
Assert.Equal(0,notepad.InquiryId);
|
||||
Assert.Equal(0, notepad.InquiryId);
|
||||
Assert.Null(notepad.Inquiry);
|
||||
Assert.Null(notepad.Notes);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestConstructorWithoutId()
|
||||
{
|
||||
NotepadEntity notepad = new NotepadEntity(_userId,_userEntity,_inquiryId,_inquiryEntity,_notes);
|
||||
Assert.Equal(0,notepad.Id);
|
||||
Assert.Equal(_userId,notepad.UserId);
|
||||
Assert.Equal(_userEntity,notepad.User);
|
||||
Assert.Equal(_inquiryId,notepad.InquiryId);
|
||||
Assert.Equal(_inquiryEntity,notepad.Inquiry);
|
||||
Assert.Equal(_notes,notepad.Notes);
|
||||
NotepadEntity notepad = new NotepadEntity
|
||||
{
|
||||
UserId = UserId,
|
||||
User = UserEntity,
|
||||
InquiryId = InquiryId,
|
||||
Inquiry = InquiryEntity,
|
||||
Notes = Notes
|
||||
};
|
||||
Assert.Equal(0, notepad.Id);
|
||||
Assert.Equal(UserId, notepad.UserId);
|
||||
Assert.Equal(UserEntity, notepad.User);
|
||||
Assert.Equal(InquiryId, notepad.InquiryId);
|
||||
Assert.Equal(InquiryEntity, notepad.Inquiry);
|
||||
Assert.Equal(Notes, notepad.Notes);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestConstructorWithAllAttributes()
|
||||
{
|
||||
NotepadEntity notepad = new NotepadEntity(_id,_userId,_userEntity,_inquiryId,_inquiryEntity,_notes);
|
||||
Assert.Equal(_id,notepad.Id);
|
||||
Assert.Equal(_userId,notepad.UserId);
|
||||
Assert.Equal(_userEntity,notepad.User);
|
||||
Assert.Equal(_inquiryId,notepad.InquiryId);
|
||||
Assert.Equal(_inquiryEntity,notepad.Inquiry);
|
||||
Assert.Equal(_notes,notepad.Notes);
|
||||
NotepadEntity notepad = new NotepadEntity
|
||||
{
|
||||
Id = Id,
|
||||
UserId = UserId,
|
||||
User = UserEntity,
|
||||
InquiryId = InquiryId,
|
||||
Inquiry = InquiryEntity,
|
||||
Notes = Notes
|
||||
};
|
||||
Assert.Equal(Id, notepad.Id);
|
||||
Assert.Equal(UserId, notepad.UserId);
|
||||
Assert.Equal(UserEntity, notepad.User);
|
||||
Assert.Equal(InquiryId, notepad.InquiryId);
|
||||
Assert.Equal(InquiryEntity, notepad.Inquiry);
|
||||
Assert.Equal(Notes, notepad.Notes);
|
||||
}
|
||||
}
|
@ -1,56 +1,69 @@
|
||||
using Entities;
|
||||
|
||||
namespace TestEF
|
||||
namespace TestEF.EntitiesTests;
|
||||
|
||||
public class TestUserEntity
|
||||
{
|
||||
public class TestUserEntity
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
UserEntity user = new UserEntity();
|
||||
Assert.Equal(0,user.Id);
|
||||
Assert.Null(user.Username);
|
||||
Assert.Null(user.Email);
|
||||
Assert.Null(user.Password);
|
||||
Assert.False(user.IsAdmin);
|
||||
}
|
||||
UserEntity user = new UserEntity();
|
||||
Assert.Equal(0, user.Id);
|
||||
Assert.Null(user.Username);
|
||||
Assert.Null(user.Email);
|
||||
Assert.Null(user.Password);
|
||||
Assert.False(user.IsAdmin);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestConstructorWithOnlyId()
|
||||
{
|
||||
UserEntity user = new UserEntity(_id);
|
||||
Assert.Equal(_id,user.Id);
|
||||
Assert.Null(user.Username);
|
||||
Assert.Null(user.Email);
|
||||
Assert.Null(user.Password);
|
||||
Assert.False(user.IsAdmin);
|
||||
}
|
||||
[Fact]
|
||||
public void TestConstructorWithOnlyId()
|
||||
{
|
||||
UserEntity user = new UserEntity{ Id = Id};
|
||||
Assert.Equal(Id, user.Id);
|
||||
Assert.Null(user.Username);
|
||||
Assert.Null(user.Email);
|
||||
Assert.Null(user.Password);
|
||||
Assert.False(user.IsAdmin);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestConstructorWithoutId()
|
||||
[Fact]
|
||||
public void TestConstructorWithoutId()
|
||||
{
|
||||
UserEntity user = new UserEntity
|
||||
{
|
||||
UserEntity user = new UserEntity(_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()
|
||||
Username = Username,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
IsAdmin = 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()
|
||||
{
|
||||
UserEntity user = new UserEntity
|
||||
{
|
||||
UserEntity user = new UserEntity(_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);
|
||||
}
|
||||
Id = Id,
|
||||
Username = Username,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
IsAdmin = 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);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue