'NUnit - how to test operation twice using custom setting each time

I would like to know how to test propertly via NUnit same operation. Each call should set parameter to static property. I am looking for similiar TestCase implementation.

Usage:

[DesktopTest, MobileTest]
public async Task ShouldA()
{
}

NUnit is using Playwright framework. Intention is to use different viewport size without passing parameter like

[TestCase("desktop")]
[TestCase("mobile")]
public async Task ShouldA(string device)
{
}

My current implementation of DesktopTest

public class DesktopTestAttribute : TestCaseAttribute
{
   public DesktopTestAttribute() : base()
   {
      TestManager.SetDevice("desktop"); // static class
   }
}

However constructor is followed by MobileTest constructor which override device.

What is proper way to not set mobile device if I run desktop target?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source