![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Creating Unit Test for Function which uses recursive dispatcher Hi, I'm having difficulty creating a unit test - perhaps some of you more experienced WPF guys out there can help out a bit. The method I'm testing (let's call it fadeVolume) calls itself recursively with a Dispatcher 60 times, sleeping for 50 milliseconds on each iteration (this is for a volume fade over the course of 3 seconds). In my unit test file, 1) I invoke fadeVolume (a private method) by an accessor class which I have created. VolumeFade_Accessor = new VolumeFade_Accessor(); accessor.volumeFade(); // should take 3 seconds performEvents(10000); // should wait while the previous statement iterates 2) performEvents does what the algorithm below shows. The wait time of 10 seconds is there just for the sake of giving my 3 second fade all the time it needs to execute. private void performEvents (int wait Time) { System.Threading.Thread.Sleep(waitTime); DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); } So the problem lies here.... even though I'm waiting for 10 seconds after I call volumeFade from my unit test file, my volumeFade method never iterates 60 times. Actually, it recursively calls itself just once, which seems very slow to me, considering that there's only a 50 millisecond sleep for each iteration. I know this method works normally, as the program normally performs as expected. It only goes wrong in this test case scenario. Can anyone give me any advice about unit testing a function which calls a dispatcher recursively?? Thanks for any help in advance. Cheers, Mike -- Mike D |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Unit Test Software | .NET General | |||
| How to unit test a Dataset? | .NET General | |||
| separate long test from unit tests in vsts | .NET General | |||
| About Creating ParameterSets for a function | PowerShell | |||