| William さんのプロフィール.Net Zoneブログリスト | ヘルプ |
|
5月6日 Generic CountdownLatch Synchronization PrimitiveThe CountdownLatch can be a very useful synchronization primitive for certain threading jobs. Here is my generic version that calls a generic Action<T> after latch reaches zero. using System; namespace WJS.Threading public CountdownLatch(int count, T state, Action<T> action) /// <summary> /// <summary> [Conditional("DEBUG")] for (int i = 0; i < 10; i++) Use Win Form in a VS Team Test library
This may be common knowledge, but I just discovered it. Test projects in VS Team Test are class libraries. Normally you write tests like a console app, with no UI. You just test api results and test results with the Assert class – nice, simple and works great. However, a lot of times, I like testing and modeling work in progress with a UI form. I just add a bunch of buttons each with some code I am testing. Works good for me as it is visually organized and double-click to see code-behind is just so natural. I use a form as a kind of scratch pad for ideas and small tests on logic. Not as a replacement for unit tests, but as dev tool. Also a nice way to create various samples for using your library. Nuf said. Anyway, I thought it would be nice to pop a form up as one of the unit tests and work with it. Kinda like a manual test. This is nice because you don't need to create yet another Project just to create Windows Form test harness and junk up your dir structure. So to keep your forms and helper class in the Test project library. Here is sort summary:
public void TestMethod1() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());
////Microsoft.VisualStudio.TestTools.UnitTesting //Form1 f1 = new Form1(); //f1.ShowDialog(); } You can either use the Application.Run method or just use ShowDialog() as shown.
Add as many forms or classes as you need. Using this method, you can collect all your samples into the same test project and distro a single library along with your other project you are testing. |
|
|