Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:23+00:00 2026-05-24T16:16:23+00:00

when I run the following example with the debugger in Visual Studio 2010 (using

  • 0

when I run the following example with the debugger in Visual Studio 2010 (using TestDriven.NET), I get a pass, but when I run it with the ReSharper test runner, I get a fail. The test is written with Microsoft’s test framework.

How can I set this up right? I basically just want to call a method with illegal input and I expect it to throw an exception.

[ExpectedException(typeof(System.Exception))]
[TestMethod]
public void TestSomething()
{
    throw new System.Exception();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:16:24+00:00Added an answer on May 24, 2026 at 4:16 pm

    Change it to use a less generic Exception (i.e, not System.Exception)

    [ExpectedException(typeof(UnauthorizedAccessException))]
    [TestMethod]
    public void TestSomething()
    {
        throw new UnauthorizedAccessException();
    }
    

    ReSharper seems to not handle ExpectedException with System.Exception that well, which in a way is good. Be specific about your exceptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the ASP.Net MVC TaskList example video and on clicking Run in Visual
Using the following example I can get a basic web server running but my
I get the following error when I try to run sample example of Google
When I run the following code to test copying a directory, I get a
i run the following example from book c++ concurrency in action, and pass function
I will be using the following example to illustrate my question: class Attribute {}
The jQuery documentation lists the following example of using $.getJSON to request JSONP: $.getJSON(http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?,
I am able to run the following example code //main class String a=Menu; Object
I know that the foreach loop used in the following example doesn't compile. But
I want to get class methods in an object. Please see the following example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.