|
|
@ -84,4 +84,49 @@ public class TestBlackListDataService
|
|
|
|
Assert.True(banResult);
|
|
|
|
Assert.True(banResult);
|
|
|
|
Assert.True(_blackListDataService.UnbanUser("example91@email.com"));
|
|
|
|
Assert.True(_blackListDataService.UnbanUser("example91@email.com"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void UnbanUser_Fail_Cause_Email_Null()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_dbContext.Users.Add(new UserEntity() { Id = 1, Username = "Test91", Email = "example91@email.com", Password = "password", IsAdmin = true });
|
|
|
|
|
|
|
|
_dbContext.Users.Add(new UserEntity() { Id = 2, Username = "Test92", Email = "example92@email.com", Password = "password", IsAdmin = false });
|
|
|
|
|
|
|
|
_dbContext.Users.Add(new UserEntity() { Id = 3, Username = "Test93", Email = "example93@email.com", Password = "password", IsAdmin = true });
|
|
|
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
var banResult = _blackListDataService.BanUser("Test91");
|
|
|
|
|
|
|
|
Assert.True(banResult);
|
|
|
|
|
|
|
|
Assert.False(_blackListDataService.UnbanUser(null));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void GetNumberOfBanned_Success()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "email@email.com", ExpirationDate = new DateOnly(2024,03,30)});
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eeemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
var banResult = _blackListDataService.GetNumberOfBannedUsers();
|
|
|
|
|
|
|
|
Assert.Equal(3,banResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void GetBannedUser_Success_Positive_Value()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "email@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eeemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
var banResult = _blackListDataService.GetBannedUsers(1,3,0);
|
|
|
|
|
|
|
|
Assert.Equal(3, banResult.Count());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void GetBannedUser_Success_Negative_Value()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "email@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.BlackLists.Add(new BlackListEntity { Email = "eeemail@email.com", ExpirationDate = new DateOnly(2024, 03, 30) });
|
|
|
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
var banResult = _blackListDataService.GetBannedUsers(-1, -3, 0);
|
|
|
|
|
|
|
|
Assert.Equal(3, banResult.Count());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|