From 2112d2a9a0004fc336345170f009fa843fe374e9 Mon Sep 17 00:00:00 2001 From: cvium Date: Wed, 17 Feb 2021 11:51:15 +0100 Subject: [PATCH] Restructure tests --- .../Users/UserManagerTests.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs index 9bcd43bc0..867dda29d 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs @@ -7,22 +7,22 @@ namespace Jellyfin.Server.Implementations.Tests.Users public class UserManagerTests { [Theory] - [InlineData("this_is_valid", true)] - [InlineData("this is also valid", true)] - [InlineData(" ", false)] - [InlineData("", false)] - [InlineData("0@_-' .", true)] - public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username, bool isValid) + [InlineData("this_is_valid")] + [InlineData("this is also valid")] + [InlineData("0@_-' .")] + public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username) { var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username)); + Assert.Null(ex); + } - var argumentExceptionNotThrown = ex is not ArgumentException; - if (ex != null) - { - Assert.Equal(typeof(ArgumentException), ex.GetType()); - } - - Assert.Equal(isValid, argumentExceptionNotThrown); + [Theory] + [InlineData(" ")] + [InlineData("")] + [InlineData("special characters like & $ ? are not allowed")] + public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username) + { + Assert.Throws(() => UserManager.ThrowIfInvalidUsername(username)); } } }