I wrote a nice little tutorial about using fakes in C#. It cover Shims and Stubs. It also covers testing private methods using the InternalsVisibleTo attribute.
https://github.com/clintcparker/c_sharp_testing/wiki/Coverage-Tutorial
Friday, March 21, 2014
VBScript Conditional Includes
VBScript Conditional Includes
This is a nasty one to track down in production, so I'm going to show you here.
VBScript has a fun way of interpreting include references that are nested inside an if statement. It will load all include references. If you have different functions, with the same name, it will use the second one.
Example
myTest_inc1.asp:
myTest_inc2.asp:
myTest.asp:
The output of myTest.asp is:
Thanks for reading.
This is a nasty one to track down in production, so I'm going to show you here.
VBScript has a fun way of interpreting include references that are nested inside an if statement. It will load all include references. If you have different functions, with the same name, it will use the second one.
Example
myTest_inc1.asp:
<%Response.Write "<br/>Function 1 loaded...<br/>"function myFunc(int1, int2)Response.Write "<br/>Function 1 executing...<br/>"myFunc = int1 * int2end function%>
myTest_inc2.asp:
<%Response.Write "<br/>Function 2 loaded...<br/>"function myFunc(int1, int2)Response.Write "<br/>Function 2 executing...<br/>"myFunc = int1 + int2end function%>
myTest.asp:
<%if (true) thenResponse.Write "<br/>Case 1 executing...<br/>"%><!-- #include file="myTest_inc1.asp" --><%elseResponse.Write "<br/>Case 2 executing...<br/>"%><!-- #include file="myTest_inc2.asp" --><%end ifResponse.Write myFunc(3,3)%>
The output of myTest.asp is:
Case 1 executing...
Function 1 loaded...
Function 2 executing...
6
Thanks for reading.
Subscribe to:
Posts (Atom)