Browse Source

Relax nullable in test projects (#5379)

* Relax nullable in test projects

* Fix xUnit Warnings

* More xUnit fixes
pull/5380/head
Justin Baur 10 months ago committed by GitHub
parent
commit
af07dffa6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      Directory.Build.props
  2. 2
      bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs
  3. 2
      bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs
  4. 1
      test/Api.IntegrationTest/Api.IntegrationTest.csproj
  5. 2
      test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs
  6. 2
      test/Core.Test/Auth/Models/Business/Tokenables/OrgUserInviteTokenableTests.cs
  7. 6
      test/Core.Test/Utilities/CoreHelpersTests.cs
  8. 2
      test/Core.Test/Utilities/EncryptedStringAttributeTests.cs
  9. 2
      test/Core.Test/Utilities/StrictEmailAddressAttributeTests.cs
  10. 2
      test/Core.Test/Utilities/StrictEmailAddressListAttributeTests.cs
  11. 7
      test/Events.IntegrationTest/Events.IntegrationTest.csproj
  12. 2
      test/Icons.Test/Models/IconLinkTests.cs
  13. 3
      test/Identity.Test/Identity.Test.csproj
  14. 6
      test/Infrastructure.Dapper.Test/Infrastructure.Dapper.Test.csproj
  15. 1
      test/Infrastructure.IntegrationTest/Infrastructure.IntegrationTest.csproj

5
Directory.Build.props

@ -8,6 +8,11 @@ @@ -8,6 +8,11 @@
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<!-- Treat it as a test project if the project hasn't set their own value and it follows our test project conventions -->
<IsTestProject Condition="'$(IsTestProject)' == '' and ($(MSBuildProjectName.EndsWith('.Test')) or $(MSBuildProjectName.EndsWith('.IntegrationTest')))">true</IsTestProject>
<Nullable Condition="'$(Nullable)' == '' and '$(IsTestProject)' == 'true'">annotations</Nullable>
<!-- Uncomment the below line when we are ready to enable nullable repo wide -->
<!-- <Nullable Condition="'$(Nullable)' == '' and '$(IsTestProject)' != 'true'">enable</Nullable> -->
</PropertyGroup>
<!--

2
bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs

@ -248,7 +248,7 @@ public class GroupsControllerTests : IClassFixture<ScimApplicationFactory>, IAsy @@ -248,7 +248,7 @@ public class GroupsControllerTests : IClassFixture<ScimApplicationFactory>, IAsy
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public async Task Post_InvalidDisplayName_BadRequest(string displayName)
public async Task Post_InvalidDisplayName_BadRequest(string? displayName)
{
var organizationId = ScimApplicationFactory.TestOrganizationId1;
var model = new ScimGroupRequestModel

2
bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs

@ -324,7 +324,7 @@ public class UsersControllerTests : IClassFixture<ScimApplicationFactory>, IAsyn @@ -324,7 +324,7 @@ public class UsersControllerTests : IClassFixture<ScimApplicationFactory>, IAsyn
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public async Task Post_InvalidEmail_BadRequest(string email)
public async Task Post_InvalidEmail_BadRequest(string? email)
{
var displayName = "Test User 5";
var externalId = "UE";

1
test/Api.IntegrationTest/Api.IntegrationTest.csproj

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

2
test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs

@ -41,8 +41,6 @@ using Xunit; @@ -41,8 +41,6 @@ using Xunit;
using Organization = Bit.Core.AdminConsole.Entities.Organization;
using OrganizationUser = Bit.Core.Entities.OrganizationUser;
#nullable enable
namespace Bit.Core.Test.Services;
[SutProviderCustomize]

2
test/Core.Test/Auth/Models/Business/Tokenables/OrgUserInviteTokenableTests.cs

@ -109,7 +109,7 @@ public class OrgUserInviteTokenableTests @@ -109,7 +109,7 @@ public class OrgUserInviteTokenableTests
[Theory]
[InlineData(null)]
[InlineData("")]
public void Valid_NullOrEmptyOrgUserEmail_ReturnsFalse(string email)
public void Valid_NullOrEmptyOrgUserEmail_ReturnsFalse(string? email)
{
var token = new OrgUserInviteTokenable
{

6
test/Core.Test/Utilities/CoreHelpersTests.cs

@ -271,7 +271,7 @@ public class CoreHelpersTests @@ -271,7 +271,7 @@ public class CoreHelpersTests
[InlineData("ascii.com", "ascii.com")]
[InlineData("", "")]
[InlineData(null, null)]
public void PunyEncode_Success(string text, string expected)
public void PunyEncode_Success(string? text, string? expected)
{
var actual = CoreHelpers.PunyEncode(text);
Assert.Equal(expected, actual);
@ -435,7 +435,7 @@ public class CoreHelpersTests @@ -435,7 +435,7 @@ public class CoreHelpersTests
[InlineData("name@", "name@")] // @ symbol but no domain
[InlineData("", "")] // Empty string
[InlineData(null, null)] // null
public void ObfuscateEmail_Success(string input, string expected)
public void ObfuscateEmail_Success(string? input, string? expected)
{
Assert.Equal(expected, CoreHelpers.ObfuscateEmail(input));
}
@ -456,7 +456,7 @@ public class CoreHelpersTests @@ -456,7 +456,7 @@ public class CoreHelpersTests
[InlineData("user@")]
[InlineData("@example.com")]
[InlineData("user@ex@ample.com")]
public void GetEmailDomain_ReturnsNull(string wrongEmail)
public void GetEmailDomain_ReturnsNull(string? wrongEmail)
{
Assert.Null(CoreHelpers.GetEmailDomain(wrongEmail));
}

2
test/Core.Test/Utilities/EncryptedStringAttributeTests.cs

@ -25,7 +25,7 @@ public class EncryptedStringAttributeTests @@ -25,7 +25,7 @@ public class EncryptedStringAttributeTests
[InlineData("Rsa2048_OaepSha256_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha256_HmacSha256_B64 as a string
[InlineData("6.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha1_HmacSha256_B64 as a number
[InlineData("Rsa2048_OaepSha1_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")]
public void IsValid_ReturnsTrue_WhenValid(string input)
public void IsValid_ReturnsTrue_WhenValid(string? input)
{
var sut = new EncryptedStringAttribute();

2
test/Core.Test/Utilities/StrictEmailAddressAttributeTests.cs

@ -47,7 +47,7 @@ public class StrictEmailAttributeTests @@ -47,7 +47,7 @@ public class StrictEmailAttributeTests
[InlineData("hellothere@world.com-")] // domain ending in hyphen
[InlineData("hellö@world.com")] // unicode at end of local-part
[InlineData("héllo@world.com")] // unicode in middle of local-part
public void IsValid_ReturnsFalseWhenInvalid(string email)
public void IsValid_ReturnsFalseWhenInvalid(string? email)
{
var sut = new StrictEmailAddressAttribute();

2
test/Core.Test/Utilities/StrictEmailAddressListAttributeTests.cs

@ -42,7 +42,7 @@ public class StrictEmailAddressListAttributeTests @@ -42,7 +42,7 @@ public class StrictEmailAddressListAttributeTests
[Theory]
[InlineData("single@email.com", false)]
[InlineData(null, false)]
public void IsValid_ReturnsTrue_WhenValid(string email, bool valid)
public void IsValid_ReturnsTrue_WhenValid(string? email, bool valid)
{
var sut = new StrictEmailAddressListAttribute();

7
test/Events.IntegrationTest/Events.IntegrationTest.csproj

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
@ -21,9 +20,9 @@ @@ -21,9 +20,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Events\Events.csproj" />
<ProjectReference Include="..\IntegrationTestCommon\IntegrationTestCommon.csproj" />
<ItemGroup>
<ProjectReference Include="..\..\src\Events\Events.csproj" />
<ProjectReference Include="..\IntegrationTestCommon\IntegrationTestCommon.csproj" />
</ItemGroup>
</Project>

2
test/Icons.Test/Models/IconLinkTests.cs

@ -45,7 +45,7 @@ public class IconLinkTests @@ -45,7 +45,7 @@ public class IconLinkTests
[InlineData(" ", false)]
[InlineData("unusable", false)]
[InlineData("ico", true)]
public void WithNoRel_IsUsable(string extension, bool expectedResult)
public void WithNoRel_IsUsable(string? extension, bool expectedResult)
{
SetAttributeValue("href", $"/favicon.{extension}");

3
test/Identity.Test/Identity.Test.csproj

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>

6
test/Infrastructure.Dapper.Test/Infrastructure.Dapper.Test.csproj

@ -3,8 +3,6 @@ @@ -3,8 +3,6 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
@ -22,8 +20,8 @@ @@ -22,8 +20,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Infrastructure.Dapper\Infrastructure.Dapper.csproj" />
<ItemGroup>
<ProjectReference Include="..\..\src\Infrastructure.Dapper\Infrastructure.Dapper.csproj" />
</ItemGroup>
</Project>

1
test/Infrastructure.IntegrationTest/Infrastructure.IntegrationTest.csproj

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<UserSecretsId>6570f288-5c2c-47ad-8978-f3da255079c2</UserSecretsId>
</PropertyGroup>

Loading…
Cancel
Save