UserManagerTests.cs 888 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using Jellyfin.Server.Implementations.Users;
  3. using Xunit;
  4. namespace Jellyfin.Server.Implementations.Tests.Users
  5. {
  6. public class UserManagerTests
  7. {
  8. [Theory]
  9. [InlineData("this_is_valid", true)]
  10. [InlineData("this is also valid", true)]
  11. [InlineData(" ", false)]
  12. [InlineData("", false)]
  13. [InlineData("0@_-' .", true)]
  14. public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username, bool isValid)
  15. {
  16. var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
  17. var argumentExceptionNotThrown = ex is not ArgumentException;
  18. if (ex != null)
  19. {
  20. Assert.Equal(typeof(ArgumentException), ex.GetType());
  21. }
  22. Assert.Equal(isValid, argumentExceptionNotThrown);
  23. }
  24. }
  25. }