I have this:
<Image.Effect>
<fx:GrayscaleEffect DesaturationFactor="0"/>
</Image.Effect>
and this:
public class GrayscaleEffect : ShaderEffect{
private static PixelShader _pixelShader = new PixelShader()
{
UriSource = new Uri(@"pack://application:,,,/Effects/GrayscaleEffect.ps")
};
/* ... rest of the class ... */
}
When I unit-test it (MSTest), it obviously raises IOException (since Application.Current is null, so pack://application:,,,/... points to nowhere) with this error:
Assembly.GetEntryAssembly() returns null. Set the Application.ResourceAssembly property or use the pack://application:,,,/assemblyname;component/ syntax to specify the assembly to load the resource from.
How do I mock/inject whatever needed to resolve it ?
Tal's answer didnt work for me, I am just calling below before running my test and Application.Current is populated:
var app = new Application();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With