<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ryan's Fleeting Thoughts and Musings</title><link>http://blogs.msdn.com/ryanvog/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Clipping legacy content hosted inside a WPF scrolling region</title><link>http://blogs.msdn.com/ryanvog/archive/2009/01/20/clipping-legacy-content-hosted-inside-a-wpf-scrolling-region.aspx</link><pubDate>Wed, 21 Jan 2009 09:38:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9355438</guid><dc:creator>Ryan Vogrinec</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/ryanvog/comments/9355438.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ryanvog/commentrss.aspx?PostID=9355438</wfw:commentRss><description>&lt;p&gt;Recently, I sat down at my computer in my home office tasked with making a better looking experience around Team Foundation Server work items. To date, we have a really cool Windows Forms version of the work item viewer inside Visual Studio but I wanted a more light-weight and portable means to view my work items. So, I chose Windows Presentation Foundation as the UI composition engine for my new work item viewer and began the task of writing a rendering engine in WPF to plug into the current Work Item store implementation. After getting neck-deep in the implementation, I encountered a nasty interop issue around the problem of &lt;a href="http://msdn.microsoft.com/en-us/library/aa970688.aspx"&gt;Airspace&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Basically, my Airspace problem is one of Z-order: when you nest Windows Forms controls inside a WPF visual container (i.e. Window, Page, Panel, etc.) the Windows Forms control actually sits on top of the WPF window and maintains its own HWND. This, in and of itself, is not a problem because the fine developers of WPF took this into consideration when they wrote the interop control &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx" target="_blank"&gt;WindowsFormsHost&lt;/a&gt;. The WindowsFormsHost control acts as a placeholder for Windows Forms content so that the WPF layout engine can treat it as a native control. &lt;/p&gt;  &lt;p&gt;You may be thinking: &amp;quot;Ok, so they figured it out...what's the big deal?&amp;quot; There is a nasty little behavior in the WindowsFormsHost that involves putting a Windows Forms control inside a WPF scrolling region (&lt;a href="http://msdn.microsoft.com/en-us/library/ms750665.aspx" target="_blank"&gt;ScrollViewer&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/photos/ryanvog/images/9355296/425x319.aspx" target="_blank"&gt;&lt;img title="Initial Repro" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="Initial Repro" src="http://blogs.msdn.com/blogfiles/ryanvog/WindowsLiveWriter/ClippinglegacycontenthostedinsideaWPFscr_13E6D/repro_initial_5.jpg" width="244" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The sample application above has a Windows Forms &lt;a href="http://msdn.microsoft.com/en-us/library/2te2y1x6.aspx" target="_blank"&gt;WebBrowser&lt;/a&gt; control inside a WPF scrolling region (along with several other controls) . This application simulates one of the conditions where lack of clipping on the hosted Windows Forms control is demonstrable. Below is the same application only with the scrolling region scrolled down until the web browser control &amp;quot;bleeds&amp;quot; through to the tab control and form above it:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/photos/ryanvog/images/9355300/425x319.aspx" target="_blank"&gt;&lt;img title="repro_scroll_past_bounds" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="184" alt="repro_scroll_past_bounds" src="http://blogs.msdn.com/blogfiles/ryanvog/WindowsLiveWriter/ClippinglegacycontenthostedinsideaWPFscr_13E6D/repro_scroll_past_bounds_3.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;What we need here is the ability to either build our own custom forms host to support clipping of the hosted content, or use some GDI APIs to clip the hosted control at the HWND level. There are pros and cons of both approaches--the custom forms host has to support a large number of state changes in the hosted control and WPF visual tree while the GDI solution is more difficult to &amp;quot;tighten the screws.&amp;quot; I'm going to talk about the second of these approaches in this blog (and will save the first for another entry).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;GDI Approach&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In order to use this approach we will derive from the WindowsFormsHost control--used by the WPF layout engine to provide a hosting platform for Win32 content. Once we have derived from this type we need to know when each of the scroll regions that we are contained within have scrolled. This can be accomplished using a class handler for the ScrollChanged event:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;EventManager.RegisterClassHandler(typeof(ScrollViewer), ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(ScrollHandler));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Once we know when each scroll region we are contained within has scrolled we need to calculate how much of the control to keep and how much to clip. This is done by first getting the viewport of the most constrained scroll viewer and translating it to the containing windows' scale:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;GeneralTransform transform = scrollViewer.TransformToAncestor(RootElement);      &lt;br /&gt;Point size = new Point(scrollViewer.ViewportWidth, scrollViewer.ViewportHeight);       &lt;br /&gt;Point location = new Point(0, 0); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;return (transform.TransformBounds(new Rect(location.X, location.Y, size.X, size.Y)));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;We will also need to grab the controls' extents and transform them to the containing windows' scale:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;Point controlSize = new Point(RenderSize.Width, RenderSize.Height);      &lt;br /&gt;Point controlLocation = new Point(Padding.Left, Padding.Right);       &lt;br /&gt;GeneralTransform controlTransform = TransformToAncestor(RootElement);       &lt;br /&gt;Rect controlTransformRect = controlTransform.TransformBounds(new Rect(controlLocation.X, controlLocation.Y, controlSize.X, controlSize.Y));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now that we have both sets of coordinates in the same scale, we can calculate the region that is the intersection between the two:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;Rect intersectRect = Rect.Intersect(scrollRect, controlTransformRect);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This gives us the portion of the control that is visibly rendered within the viewport of the scroll region. Now that we have the visible region needed we can use the SetWindowRgn GDI function to perform the clipping for us:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;[DllImport(&amp;quot;User32.dll&amp;quot;, SetLastError = true)]      &lt;br /&gt;private static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It is important to note that you will need to have the HWND of the control that the WPF interop control uses to synchronize the placeholder WPF element with your Windows Forms control.&amp;#160; Using reflection you can easily query the interop control for this handle&amp;#160; If you plan to support more than one font size (i.e. DPI) you will need to adjust your measurements accordingly:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="1"&gt;CompositionTarget ct = source.CompositionTarget;      &lt;br /&gt;Matrix m = ct.TransformToDevice;       &lt;br /&gt;Point transformed = m.Transform(p);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Once you have the clipping code in place the result will be a Windows Forms control that clips correctly inside a WPF scrolling region:&lt;/p&gt;  &lt;p&gt;&lt;img title="fixed_initial" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="fixed_initial" src="http://blogs.msdn.com/blogfiles/ryanvog/WindowsLiveWriter/ClippinglegacycontenthostedinsideaWPFscr_13E6D/fixed_initial_3.jpg" width="244" border="0" /&gt; &lt;a href="http://blogs.msdn.com/photos/ryanvog/images/9355309/425x319.aspx"&gt;&lt;img title="fixed_scroll" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="fixed_scroll" src="http://blogs.msdn.com/blogfiles/ryanvog/WindowsLiveWriter/ClippinglegacycontenthostedinsideaWPFscr_13E6D/fixed_scroll_3.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9355438" width="1" height="1"&gt;</description></item><item><title>Right-Click Test Execution</title><link>http://blogs.msdn.com/ryanvog/archive/2007/08/05/right-click-test-execution.aspx</link><pubDate>Mon, 06 Aug 2007 07:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4251428</guid><dc:creator>Ryan Vogrinec</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ryanvog/comments/4251428.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ryanvog/commentrss.aspx?PostID=4251428</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t202 coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:path gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;/v:shapetype&gt;&lt;v:shape id=_x0000_s1026 style="MARGIN-TOP: 276.4pt; Z-INDEX: 2; MARGIN-LEFT: 0.9pt; WIDTH: 114.3pt; POSITION: absolute; HEIGHT: 31.8pt" type="#_x0000_t202" stroked="f"&gt;&lt;v:textbox style="mso-fit-shape-to-text: t" inset="0,0,0,0"&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" style="BORDER-RIGHT: #f0f0f0; BORDER-TOP: #f0f0f0; BORDER-LEFT: #f0f0f0; BORDER-BOTTOM: #f0f0f0; BACKGROUND-COLOR: transparent"&gt;
&lt;DIV&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/v:textbox&gt;&lt;?xml:namespace prefix = w ns = "urn:schemas-microsoft-com:office:word" /&gt;&lt;w:wrap type="square"&gt;&lt;/w:wrap&gt;&lt;/v:shape&gt;&lt;v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f" o:preferrelative="t" filled="f"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape id=Picture_x0020_0 style="MARGIN-TOP: 72.1pt; Z-INDEX: 1; VISIBILITY: visible; MARGIN-LEFT: 0.9pt; WIDTH: 114.3pt; POSITION: absolute; HEIGHT: 199.8pt; mso-wrap-style: square; mso-wrap-distance-left: 9pt; mso-wrap-distance-top: 0; mso-wrap-distance-right: 9pt; mso-wrap-distance-bottom: 0; mso-position-horizontal: absolute; mso-position-horizontal-relative: text; mso-position-vertical: absolute; mso-position-vertical-relative: text" type="#_x0000_t75" o:spid="_x0000_s1027" alt="RightClickExecution.jpg"&gt;&lt;/v:shape&gt;&lt;FONT face=Calibri size=3&gt;One of the great new features of Visual Studio 2008 is the ability to run your unit tests from the context of a test method or a test class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This feature is known as right-click execution and provides a mouse-based complement to &lt;/FONT&gt;&lt;A class="" title="keyboard shortcuts" href="http://msdn2.microsoft.com/en-us/library/ms182470(vs.90).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/ms182470(vs.90).aspx"&gt;&lt;FONT face=Calibri size=3&gt;keyboard shortcuts&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; for running a single test method or all the test methods in a test class or test assembly.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-pagination: widow-orphan lines-together"&gt;&lt;FONT face=Calibri size=3&gt;When working with unit tests it is often useful to be able to run the current test method or all tests in the current test class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This can be accomplished via the new &lt;B style="mso-bidi-font-weight: normal"&gt;Run Tests&lt;/B&gt; menu option on the unit test context menu (Fig. 1). &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;As you can see, the &lt;B style="mso-bidi-font-weight: normal"&gt;Run Tests&lt;/B&gt; menu option sits at the top of the unit test context menu, below the refactoring options.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Clicking this menu option will execute your tests in the current scope—where you are in your test project.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, if you right-click inside a test method, &lt;B style="mso-bidi-font-weight: normal"&gt;Run Tests&lt;/B&gt; will run just that test method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;If you right-click inside a test class, but not inside an actual test method—i.e. a method with the &lt;/FONT&gt;&lt;A class="" title=TestMethodAttribute href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testmethodattribute(vs.90).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testmethodattribute(vs.90).aspx"&gt;&lt;FONT face=Calibri size=3&gt;TestMethodAttribute&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; attribute—&lt;B style="mso-bidi-font-weight: normal"&gt;Run Tests&lt;/B&gt; will run all the tests in the test class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Last but not least, if you right-click inside a test project but neither inside a test method nor inside a test class, &lt;B style="mso-bidi-font-weight: normal"&gt;Run Tests&lt;/B&gt; will run all tests in the test project.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-pagination: widow-orphan lines-together"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;w:wrap type="square"&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/picture4251352.aspx" target=_blank&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4251352/original.aspx" border=0&gt;&lt;/A&gt;&lt;/w:wrap&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-pagination: widow-orphan lines-together"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&lt;w:wrap type="square"&gt;Figure 1: Unit Test Context Menu&lt;/w:wrap&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4251428" width="1" height="1"&gt;</description></item><item><title>Test Generation from a Compiled Assembly</title><link>http://blogs.msdn.com/ryanvog/archive/2007/07/31/test-generation-from-a-compiled-assembly.aspx</link><pubDate>Wed, 01 Aug 2007 02:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4155958</guid><dc:creator>Ryan Vogrinec</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ryanvog/comments/4155958.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ryanvog/commentrss.aspx?PostID=4155958</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Visual Studio 2008&amp;nbsp;(Codename&amp;nbsp;"Orcas") can generate a basic test project including test classes and test methods from your C#, VB, or managed C++ source code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But did you know it can also generate the same test project/classes/methods against a compiled assembly?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;In order to generate these tests, you will first need to compile an&amp;nbsp;assembly.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The assembly may be compiled from C#, Visual Basic .NET, or managed C++.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Once you have your compiled assembly handy, open Visual Studio 2008, show the “Test View” tool window if it is not already showing (Test|Windows|Test View) and click on the “Create New Test” hyperlink in the middle of the tool window.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You will get a dialog like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/picture4155051.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/picture4155051.aspx"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Calibri&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155051/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155051/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155051/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155051/thumb.aspx"&gt;&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Calibri&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;1&lt;/SPAN&gt;: Add New Test&lt;SPAN style="mso-no-proof: yes"&gt; Dialog&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Choose “Unit Test Wizard” and click “OK.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You will be prompted for a project name with a preset value.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Once you have named your new project, click “OK” again and you will be taken to the “Create Unit Test” dialog:&lt;/SPAN&gt; 
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155135/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155135/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155135/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155135/thumb.aspx"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;2&lt;/SPAN&gt;: Create Unit Test Dialog&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;On the “Create Unit Test” dialog you will see a button at the bottom labeled “Add Assembly.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This feature will allow you to add a managed assembly to the list of assemblies currently displayed in the tree view above. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Click the “Add Assembly…” button and choose your assembly. After clicking “OK” in the file chooser dialog you will be taken back to the “Create Unit Test” dialog and it will be populated with the types and members&amp;nbsp;(in hierarchical order) from your assembly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155117/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155117/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155117/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155117/thumb.aspx"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd size=2&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;3&lt;/SPAN&gt;: Create Unit Test Dialog with Types&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;You can choose the members for which you would like to generate tests by clicking the checkbox next to each name.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Once you have chosen the types you want to generate, click “OK” and the test generation engine will create a new test project in a new solution and generate basic test methods for all the types chosen in the types tree.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Below is a sample test project created for a compiled assembly:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155155/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155155/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155155/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155155/thumb.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd size=2&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;4&lt;/SPAN&gt;: Visual Studio with Test Project&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;You will have a test class file for each class in your CUT—Code Under Test—assembly.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In each test class file, you will see a test method for each method in your CUT class with the suffix “Test.”&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155179/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155179/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155179/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155179/thumb.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT color=#4f81bd size=2&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;5&lt;/SPAN&gt;: Visual Studio with Open Test Class&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;If your assembly contains private types, our private accessor engine will create a “wrapper” assembly around your private types allowing you to test them via the test project.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In the sample above, notice that there is a Test Reference called “ConsoleApplication5.accessor” in your solution explorer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is a reference to the wrapper assembly—called an Accessor assembly—and will be what you use in your test code instead of the CUT type name when you want to author tests against a private type in the CUT assembly. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;We add &lt;SPAN class=MsoIntenseEmphasis&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#4f81bd&gt;Inconclusive&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=MsoIntenseEmphasis&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#4f81bd&gt;assertions&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; to each of the test methods generated to be a reminder that you may need to add valid arguments and assertions inside each test method for testing the corresponding CUT method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;An example of this is in Figure 5 at the bottom of the &lt;SPAN class=MsoIntenseEmphasis&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#4f81bd&gt;ProgramConstructorTest&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The assertion &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Assert&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;.Inconclusive(&lt;SPAN style="COLOR: #a31515"&gt;"TODO: Implement code to verify target"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;is added by the test generation engine to remind you that you need to fill out the rest of the test method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case, you need to make sure that your target object reference contains a valid object reference:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Assert&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;.IsNotNull(target);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;You can run the test project at any time, including before you have completed the remaining test methods.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Below are a couple of screen shots taken before and after all the remaining test methods are filled in:&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155217/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155217/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155217/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155217/thumb.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;6&lt;/SPAN&gt;: Test Results before Completing Test Methods&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;&lt;A href="http://blogs.msdn.com/photos/ryanvog/images/4155242/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/ryanvog/images/4155242/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/ryanvog/images/4155242/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ryanvog/images/4155242/thumb.aspx"&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt"&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure &lt;SPAN style="mso-no-proof: yes"&gt;7&lt;/SPAN&gt;: Test Results after Completing Test Methods&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;That’s it!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can now write test code against a compiled assembly including testing private/internal types and members via the private accessor wrapper type.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoCaption style="MARGIN: 0in 0in 10pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4155958" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ryanvog/archive/tags/tsbt-tst/default.aspx">tsbt-tst</category></item></channel></rss>