Fix parsing localization cookie when the value is not present
This commit is contained in:
30
Oqtane.Test/Oqtane.Client.Tests/LocalizationCookieTests.cs
Normal file
30
Oqtane.Test/Oqtane.Client.Tests/LocalizationCookieTests.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Xunit;
|
||||
|
||||
namespace Oqtane.Oqtane.Client.Tests
|
||||
{
|
||||
public class LocalizationCookieTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("c=ar|uic=ar", "ar")]
|
||||
[InlineData("c=ar", null)]
|
||||
[InlineData("", null)]
|
||||
[InlineData(null, null)]
|
||||
public void ParseCookie(string localizationCookie, string expectedCulture)
|
||||
{
|
||||
// Arrange
|
||||
var localizationCookieValue = CookieRequestCultureProvider.ParseCookieValue(localizationCookie);
|
||||
|
||||
// Act
|
||||
var culture = localizationCookieValue?.UICultures?[0].Value;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedCulture, culture);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,8 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
|
||||
<PackageReference Include="bunit.web" Version="1.0.0-beta-10" />
|
||||
<PackageReference Include="bunit.xunit" Version="1.0.0-beta-10" />
|
||||
|
Reference in New Issue
Block a user