Calling VS 2005 tests from Windows forms test harness

I like VS 2005 Team System ability to generate test cases. Using it with TestDriven.Net “Test with Debugger” allows quickly debug and test a new or existing code.
However if you do a relatively long debugger session with multiple edit changes, the test session is often interrupted.

I found that “Edit and Continue” for Windows form(or console) application is more stable. 
So my question was: can I call TestMethod from Windows form test harness?

The answer is YES, no problem.
You need to add reference to your TestCases Project( just as any other class library) and call required methods from Windows form.By the way, the same approuact will work wit NUnit as well.
For example:

      private void btnImportTest_Click(object sender, EventArgs e)

        {

            try
            {
            MyClassTest test = new MyClassTest();
            test.MyMethodTest();
            }
            catch (Exception exc)
            {
                 Debug.WriteLine(exc.ToString());
                 MessageBox.Show(exc.ToString());
            }

       

By putting the call inside try block allow you to restart your test many times without re-compile, and using Debug.WriteLine shows exception details, including line number to output window, which is easy to navigate to set breakpoints.  

}

Unreadable characters in Web Services string parameter can cause HTTP status 400: Bad Request

I have a web service that sends USMARC record as string. USMARC uses unreadable characters Chr(29)/Chr(30)/Chr(31) as separators.

 MS web services XMLSerializer doesn't encode these characters and causes
System.Net.WebException: "The request failed with HTTP status 400: Bad Request".
Interesting to note that the error not happened if test the operation using the HTTP POST protocol or if a string is incorporated into Dataset record.
I am using simple Encode/Decode functions to workaround the issue.

TODO: It would be better to use standard encoding technique,described in MSDN and implemented in XmlTextWriter.WriteString Method   “Character values 0x-0x1F are encoded as numeric character entities � through , except for the white space characters 0x9, 0x10, and 0x13.“

    'there is complimentary function before SOAP send to encode the characters
    'Can't send the special characters in soap 'caused  "HTTP status 400-Bad Request" 
    Public Shared Function USMARCSpecialCharactersEncode(ByVal str As String) As String

        str = Replace(str, Chr(30), "{30}")

        str = Replace(str, Chr(31), "{31}")

        str = Replace(str, Chr(29), "{29}")

        Return str

    End Function

    'there is complimentary function after SOAP receive to decode the characters

    Public Shared Function USMARCSpecialCharactersDecode(ByVal str As String) As String

        str = Replace(str, "{29}", Chr(29))

        str = Replace(str, "{30}", Chr(30))

        str = Replace(str, "{31}", Chr(31))

        Return str

    End Function

 

 

Ado.Net 2.0 How SqlCommandBuilder works.

I've debugged my code that uses SqlCommandBuilder:

Dim daJoinTable As New SqlDataAdapter(sSQLSelect,connString)
Dim
cbJoinTable As New SqlCommandBuilder(daJoinTable)
daJoinTable.Update(dsJoinTable.Tables(0))

and noticed that daJoinTable.UpdateCommand,InsertCommand and DeleteCommand are nulls, when I expected that they will be generated by SqlCommandBuilder.
Even itf code works fine, I was curious, how dataadapter knows which 
 update SQL command should be used. I gound a good article about SqlCommandBuilder, but it desn't go into this level of details.

With help of Reflector, I understood that  SqlCommandBuilder constructor calls SetRowUpdatingHandler(DbDataAdapter adapter), to use protected DbCommandBuilder.RowUpdatingHandler when row is about to be updated.
The implementation of  RowUpdatingHandler replaces null commands with commands generated by DbCommandBuilder for each updated row.

«July»
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345