Awareness of user control TestContainer

  • Thread starter Thread starter michael sorens
  • Start date Start date
M

michael sorens

In my code for a custom user control, is there a way to determine whether or
not I am inside the standard user control TestContainer? I was hoping that I
could perhaps examine a unique characteristic of the parent, if it is
accessible. Ultimately what I would like to do is exercise more of my custom
control than just seeing how it renders, something along the lines of: if
inside the TestContainer, then show a hidden "Step" button. I could then
press the Step button to make the control do some action; press it again for
the next action, etc.

I am running VS2008, with .NET 2 or 3 or 3.5.
 
Hi Michael,

As or the custom user control, do you mean the ascx user control(or a
custom server control)?

I'm still not quite sure about the "TestContainer" you mentioned, is it the
parent container of a control on page at runtime?Generally, for any ASP.NET
server control on page, it will have a NamingContainer(if it is not the top
level control), and this NamingContainer will affect the control's actual
UniqueID and ClientID when rendering. Control can access its
NamingContainer through the "NamingContainer" property at runtime.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
Sorry for the ambiguity... this is a WinForm not a WebForm. The User Control
TestContainer is a vehicle of Visual Studio that automatically runs a user
control when you press F5 for a user control library project.
 
Thanks for the reply Michael,

Seems I also incorrectly assume that this is an ASP.NET issue(as I often
see your posts on ASP.NET :) ).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <[email protected]>
References: <[email protected]>
 
Hi Michael,

Thank you for your reply!

Based on my understanding, you have a user control class library project
which contains a custom user control and you create a test project for the
custom user control. What you want is to determine from within the custom
control's code whether the custom control is created inside a test
container. If I'm off base, please feel free to let me know.

IMO, the custom control has no chance to know whether it is created inside
a test container or not. All classes and methods provided by the Unit
Testing Framework are used in test class and methods, rather that in the
classes or methods to test.

A workaround of your question is to add a property of type bool in the
custom control to indicate whether it is initialized inside a test
container or not. The default value of this property is false. You can set
this property to true from within the test method. You can then decide how
the custom control renders depending on this bool property.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top