Question: Unable to load Resources

Sep 20, 2011 at 5:35 PM

I have duplicated my app.xaml in the silverlight test project, when I use the browser test runner they are found, but when I run through resharper 6 (agunit) the app.xaml resources are not found. Do I need to put them somewhere special?

 

Thanks,

Ben

Sep 21, 2011 at 10:19 AM
Edited Sep 21, 2011 at 10:20 AM

I don't think the App.xaml is ever loaded.
This is done by the Statlight runner. So you might have more luck searching it's codeplex and github pages: http://statlight.codeplex.com/ and https://github.com/staxmanade/statlight 

We usually try to avoid using styles, but if we do, we use an AssemblyInitialize fixture (MSTest). Example:

    [TestClass]
    public class StylesSetup
    {
        [AssemblyInitialize]
        public void Setup_StyleManager()
        {
            RegisterStyles<DummyApp1.App>("Styles/Styles.xaml");
            RegisterStyles<DummyApp2.App>("Styles/Styles.xaml");
        }

        private void RegisterStyles<T>(string stylesPath)
        {
            var uri = new Uri(string.Format("/{0};component/{1}", typeof(T).Namespace, stylesPath), UriKind.RelativeOrAbsolute);

            Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = uri });
        }

        [TestMethod]
        public void StyleSetup_EmptyTest()
        { }
    }