none
Advance unit test scenarios for SQL server RRS feed

  • Question

  • my company has developed data access layer in .net which perfroms retry operations of sql connection or command based on sql error. I want to write unit test cases such that below error will be thrown by sql server (and it performs retry until max retry count exceed). Can anybody help me to prepare the envionment such that below exceptions are thrown by sql server 2008 R?

     

    any kind of help would be appreciated.

     

    Thanks.

     SQL error numbers

    -2:  Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
     0: A severe error occurred on the current command.  The results, if any, should be discarded
     64: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)                           

    1222: Lock request time out period exceeded. The statement has been terminated.
    10060: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

    -1: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configuredto allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    315: Index "%.*ls" on table "%.*ls" (specified in the FROM clause) is disabled or resides in a filegroup which is not online

    652: The index "%.*ls" for table "%.*ls" (RowsetId %I64d) resides on a read-only filegroup ("%.*ls"), which cannot be modified.

    667: The index "%.*ls" for table "%.*ls" (RowsetId %I64d) resides on a filegroup ("%.*ls") that cannot be accessed because it is offline,
                     * is being restored, or is defunct.

    670: Large object (LOB) data for table "%.*ls" resides on an offline filegroup ("%.*ls") that cannot be accessed.

    671: Large object (LOB) data for table "%.*ls" resides on a read-only filegroup ("%.*ls"), which cannot be modified.

    679: One of the partitions of index '%.*ls' for table '%.*ls'(partition ID %I64d) resides on a filegroup ("%.*ls") that cannot be accessed because it is offline, restoring, or defunct. This may limit the query result.

    1205: Transaction (Process ID %d) was deadlocked on %.*ls resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

    1206: The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

    3906: Failed to update database %s because the database is read-only.

    Monday, February 7, 2011 6:06 AM

Answers