Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I want to unit test a subroutine.
The code is like this.
VB
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
    connect.Open()

    'Connecting the sql command with the database.
    command.Connection = connect

    command.ExecuteNonQuery()
    LoadChatData()
    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
Updated 26-Sep-12 19:13pm
v2
Comments
josephSurgeon 1-Oct-12 10:40am    
I think you have the wrong Idea about unit testing. see here

http://msdn.microsoft.com/en-us/library/ms182532.aspx

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900