I created some tests for my SetDesktopWallpaper() static method with xUnit.
As its name implies, it changes the current users's desktop wallpaper.
Here is one of my tests.
[Theory]
[InlineData(@".\Resources\JpgWallpaper.jpg")]
[InlineData(@".\Resources\PngWallpaper.png")]
public void Changing_Wallpaper_File_Should_Work(string value)
{
const string keyName = @"HKEY_CURRENT_USER\Control Panel\Desktop";
const string keyVal1 = "WallPaper";
WallChanger.SetDesktopWallpaper(value);
Assert.Equal(Path.GetFullPath(value), Registry.GetValue(keyName, keyVal1, null).ToString());
}
I would like it to save the current wallpaper at the beginning of the tests and put it back at the end. How to achieve this with xUnit?