parent
99471a3705
commit
c4dd76334d
@ -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);
|
||||
}
|
||||
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()
|
||||
[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