Enable TreatWarningsAsErrors and Nullable for test projects

This commit is contained in:
Bond_009 2020-01-31 22:46:10 +01:00
parent cd13f718fb
commit 71abf1d3ce
8 changed files with 22 additions and 10 deletions

View File

@ -1,3 +1,5 @@
#nullable enable
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
@ -7,6 +9,6 @@ namespace MediaBrowser.Controller.Net
public interface IAuthService
{
void Authenticate(IRequest request, IAuthenticationAttributes authAttribtues);
User Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues);
User? Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues);
}
}

View File

@ -83,7 +83,7 @@ namespace Jellyfin.Api.Tests.Auth
a => a.Authenticate(
It.IsAny<HttpRequest>(),
It.IsAny<AuthenticatedAttribute>()))
.Returns((User)null);
.Returns((User?)null);
var authenticateResult = await _sut.AuthenticateAsync();

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -9,15 +9,15 @@ namespace Jellyfin.MediaEncoding.Tests
{
public class EncoderValidatorTests
{
private class GetFFmpegVersionTestData : IEnumerable<object[]>
private class GetFFmpegVersionTestData : IEnumerable<object?[]>
{
public IEnumerator<object[]> GetEnumerator()
public IEnumerator<object?[]> GetEnumerator()
{
yield return new object[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) };
yield return new object[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) };
yield return new object[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) };
yield return new object[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) };
yield return new object[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null };
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
@ -25,7 +25,7 @@ namespace Jellyfin.MediaEncoding.Tests
[Theory]
[ClassData(typeof(GetFFmpegVersionTestData))]
public void GetFFmpegVersionTest(string versionOutput, Version version)
public void GetFFmpegVersionTest(string versionOutput, Version? version)
{
Assert.Equal(version, EncoderValidator.GetFFmpegVersion(versionOutput));
}

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<!-- TODO: <TreatWarningsAsErrors>true</TreatWarningsAsErrors> -->
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<RootNamespace>Jellyfin.Server.Implementations.Tests</RootNamespace>
</PropertyGroup>