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 6943883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:12:51+00:00 2026-05-27T13:12:51+00:00

I have written a unit test with MD 2.8.5 in a project that includes

  • 0

I have written a unit test with MD 2.8.5 in a project that includes System.Core and with build target Mono/.NET 3.5. I really like the Assert.Throws of the newer NUnit, so decided to write an extension method for it. I created a new file with this as its content in the same namespace as the test. Can anyone see my error?

public delegate void TestDelegate();

public static class AssertThrows
{
    public static T Throws<T>(this Assert assert, TestDelegate td)
        where T : Exception
    {
        try
        {
            td();
        }
        catch(T e)
        {
            return e;
        }
        catch
        {
            throw new AssertionException("Wrong exception type.");
        }
        throw new AssertionException("Did not throw an error.");
    }
}

MonoDevelop “sees” the extension method through its code completion. However, the compiler reports:

Performing main compilation...
/Users/shamwow/dev/EngineTests.cs(19,37): error CS0117:
  `NUnit.Framework.Assert' does not  contain a definition for `Throws'
/Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.framework.dll (Location of the symbol related to previous error)


Build complete -- 1 error, 0 warnings

(I know MD and Mono are not the same.)

  • 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-27T13:12:51+00:00Added an answer on May 27, 2026 at 1:12 pm

    I assume you’re trying to use it just as:

    Assert.Throws<FooException>(() => ...);
    

    Extension methods don’t work like that – they appear to be instance methods on the extended type. As you won’t have an instance of Assert, you can’t call your extension method like that.

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

Sidebar

Related Questions

I have different projects written in .NET 3.5 and some unit test projects to
I have some written a number of unit tests that test a wrapper around
We’ve found that the unit tests we’ve written for our C#/C++ code have really
I have written a small unit test for my django view .My project structure
I'm writing unit tests for a project (written in PHP, using PHPUnit) that have
I have a simple PoC project in Hudson. The PoC has unit tests written
I have a simple project on C#.NET and have written it in Visual Studio
Let's say you got a project that is really poorly written, contains lots of
I am working on a distributed solution (written in .NET) that includes WCF services,
I have several session beans that I have written unit tests for. I have

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.