parent
99471a3705
commit
c4dd76334d
@ -1,56 +1,69 @@
|
|||||||
using Entities;
|
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";
|
UserEntity user = new UserEntity();
|
||||||
private const string _email = "example@email.com";
|
Assert.Equal(0, user.Id);
|
||||||
private const string _password = "password";
|
Assert.Null(user.Username);
|
||||||
private const bool _isAdmin = true;
|
Assert.Null(user.Email);
|
||||||
private const int _id = 42;
|
Assert.Null(user.Password);
|
||||||
[Fact]
|
Assert.False(user.IsAdmin);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestConstructorWithOnlyId()
|
public void TestConstructorWithOnlyId()
|
||||||
{
|
{
|
||||||
UserEntity user = new UserEntity(_id);
|
UserEntity user = new UserEntity{ Id = Id};
|
||||||
Assert.Equal(_id,user.Id);
|
Assert.Equal(Id, user.Id);
|
||||||
Assert.Null(user.Username);
|
Assert.Null(user.Username);
|
||||||
Assert.Null(user.Email);
|
Assert.Null(user.Email);
|
||||||
Assert.Null(user.Password);
|
Assert.Null(user.Password);
|
||||||
Assert.False(user.IsAdmin);
|
Assert.False(user.IsAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestConstructorWithoutId()
|
public void TestConstructorWithoutId()
|
||||||
|
{
|
||||||
|
UserEntity user = new UserEntity
|
||||||
{
|
{
|
||||||
UserEntity user = new UserEntity(_username, _password, _email, _isAdmin);
|
Username = Username,
|
||||||
Assert.Equal(0,user.Id);
|
Password = Password,
|
||||||
Assert.Equal(_username, user.Username);
|
Email = Email,
|
||||||
Assert.Equal(_email, user.Email);
|
IsAdmin = IsAdmin
|
||||||
Assert.Equal(_password, user.Password);
|
};
|
||||||
Assert.True(user.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]
|
[Fact]
|
||||||
public void TestConstructorWithoutAllAttributes()
|
public void TestConstructorWithoutAllAttributes()
|
||||||
|
{
|
||||||
|
UserEntity user = new UserEntity
|
||||||
{
|
{
|
||||||
UserEntity user = new UserEntity(_id, _username, _password, _email, _isAdmin);
|
Id = Id,
|
||||||
Assert.Equal(_id,user.Id);
|
Username = Username,
|
||||||
Assert.Equal(_username, user.Username);
|
Password = Password,
|
||||||
Assert.Equal(_email, user.Email);
|
Email = Email,
|
||||||
Assert.Equal(_password, user.Password);
|
IsAdmin = IsAdmin
|
||||||
Assert.True(user.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