How to test silverlight behaviors using Rhino Mocks?
Posted
by Derek
on Stack Overflow
See other posts from Stack Overflow
or by Derek
Published on 2010-06-08T03:11:34Z
Indexed on
2010/06/08
3:22 UTC
Read the original article
Hit count: 302
I have slightly adapted the custom behavior code that can be found here: http://www.reflectionit.nl/blog/default.aspx?guid=d81a8cf8-0345-48ee-bbde-84c2e3f21a25 that controls a MediaElement.
I need to know how to go about testing this with Rhino Mocks e.g. how to instantiate a new ControlMediaElementAction in test code and then call the Invoke method etc.
Doing something simple like this in test code: mMediaElementControlBehaviour = new ControlMediaElementAction (); gives me an exception "The type initializer for 'System.Windows.DependencyObject' throw an exception.
Thinking it was the instantiation of the MediaElement, I tried this two lines of code: MediaElement mediaElementStub = MockRepository.GenerateStub(); this.Container.RegisterInstance(mediaElementStub); This gave the exception 'Can't create mocks of sealed classes'
If someone can point me in the right direction, it would be apreciated.
Silverlight 4, Rhino Mocks 3.5 Silverlight v2.0.50727
Thanks,
© Stack Overflow or respective owner