Click here to Skip to main content
11,639,126 members (63,985 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Visual-Studio testing , +

I want to unit test a subroutine.
The code is like this.
    Public Sub UpdateChat()
        'Getting the connection string
        Dim connectString As String = ConfigurationManager.ConnectionStrings("ShoutDb").ConnectionString
        'Creating connection object
        Dim connect As SqlConnection = New SqlConnection(connectString)
        'Declaring variable to store sqlcommand
        Dim command As New SqlCommand
        'Initialising the sql command to the varaible
        command.CommandText = "INSERT INTO [ShoutBox].[dbo].[CommonShout]([UserName],[Message],[SubmitTime]) VALUES('" & Session("UserName").ToString & "','" & smiley() & "',Convert(datetime,'" & DateTime.Now.ToString & "',120))"
        'Connecting to database
        'Connecting the sql command with the database.
        command.Connection = connect
        Me.TxtMessage.Text = String.Empty
    End Sub
With the help of unit testing i want to test the above function for whether the subroutine has inserted the data into the database or not. How to accomplish this? Need help. I am new to testing.
Posted 26-Sep-12 19:06pm
Edited 26-Sep-12 19:13pm
(no name)115.2K
josephSurgeon at 1-Oct-12 10:40am
I think you have the wrong Idea about unit testing. see here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 280
1 Sergey Alexandrovich Kryukov 279
2 Richard Deeming 200
3 CPallini 187
4 PIEBALDconsult 175
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,812
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,600
4 F-ES Sitecore 2,548

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100