mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Restructure tests
This commit is contained in:
parent
442e770688
commit
2112d2a9a0
@ -7,22 +7,22 @@ namespace Jellyfin.Server.Implementations.Tests.Users
|
|||||||
public class UserManagerTests
|
public class UserManagerTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("this_is_valid", true)]
|
[InlineData("this_is_valid")]
|
||||||
[InlineData("this is also valid", true)]
|
[InlineData("this is also valid")]
|
||||||
[InlineData(" ", false)]
|
[InlineData("0@_-' .")]
|
||||||
[InlineData("", false)]
|
public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username)
|
||||||
[InlineData("0@_-' .", true)]
|
|
||||||
public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username, bool isValid)
|
|
||||||
{
|
{
|
||||||
var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
|
var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
|
||||||
|
Assert.Null(ex);
|
||||||
|
}
|
||||||
|
|
||||||
var argumentExceptionNotThrown = ex is not ArgumentException;
|
[Theory]
|
||||||
if (ex != null)
|
[InlineData(" ")]
|
||||||
{
|
[InlineData("")]
|
||||||
Assert.Equal(typeof(ArgumentException), ex.GetType());
|
[InlineData("special characters like & $ ? are not allowed")]
|
||||||
}
|
public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username)
|
||||||
|
{
|
||||||
Assert.Equal(isValid, argumentExceptionNotThrown);
|
Assert.Throws<ArgumentException>(() => UserManager.ThrowIfInvalidUsername(username));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user