SetUICultureAttribute
Sets the current UI Culture on an assembly, test fixture or test method
for the duration of a test. The UI culture remains set until the test or
fixture completes and is then reset to its original value.
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace NUnit.Framework
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class SetUICultureAttribute : PropertyAttribute, IApplyToContext
{
private readonly string _culture;
public SetUICultureAttribute(string culture)
: base("SetUICulture", culture)
{
_culture = culture;
}
void IApplyToContext.ApplyToContext(TestExecutionContext context)
{
context.CurrentUICulture = new CultureInfo(_culture, false);
}
}
}