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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:05:25+00:00 2026-06-03T06:05:25+00:00

I’m trying to implement on a very big and bloating system a framework to

  • 0

I’m trying to implement on a very big and bloating system a framework to use unit testing, the main problem is that 70% of the system is implemented with static methods. Is how I’ve reached Moles, and I’m very confident that I will reach my goal (I’m quite near).

The problem I have right now is that I’m trying to mole a static method with a Generic Parameter:

public static T ExecScalar<T>(IDbConnection cx, string commandText, IDbTransaction tx, IEnumerable<IDbDataParameter> parameters)

googling on the web I’ve found this forum message:

http://social.msdn.microsoft.com/Forums/uk/pex/thread/3faadca2-a26f-449c-942e-d800a6079e02

that is exactly my problem, and there is suggested to read the manual at page 10.

I’ve read the manual at page 10, but it’s talking about stubbing and not molling. I ‘ve tried to apply the described solution but if I put:

Ktcar.Cs.Dal.DB.Moles.MDALDB.ExecScalarIDbConnectionStringIDbTransactionIEnumerableOfIDbDataParameter<int> = delegate(IDbConnection conn, String command, IDbTransaction trx, IEnumerable<IDbDataParameter> parameters)

I get:

“Only assignment, call, increment, decrement, and new object expressions can be used as a statement”

I have also tried:

Ktcar.Cs.Dal.DB.Moles.MDALDB.ExecScalarIDbConnectionStringIDbTransactionIEnumerableOfIDbDataParameter<T> = delegate(IDbConnection conn, String command, IDbTransaction trx, IEnumerable<IDbDataParameter> parameters)

And I get the same error

Or:

Ktcar.Cs.Dal.DB.Moles.MDALDB.ExecScalarIDbConnectionStringIDbTransactionIEnumerableOfIDbDataParameter = null;

And then I get:

“Cannot assign to ‘ExecScalarIDbConnectionStringIDbTransactionIEnumerableOfIDbDataParameter’ because it is a ‘method group’”

please, can anyone helpme on how to mock a static method with Generic Type output?

  • 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-06-03T06:05:26+00:00Added an answer on June 3, 2026 at 6:05 am

    Try this one:

    Ktcar.Cs.Dal.DB.Moles.MDALDB.ExecScalarIDbConnectionStringIDbTransactionIEnumera‌​bleOfIDbDataParameter<int>((IDbConnection conn, String command, IDbTransaction trx, IEnumerable<IDbDataParameter> parameters) => { return 5; }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a very basic system from my C# .NET application
I'm trying to implement a very simple WCF service that returns JSON. I'm trying
I'm trying to implement a very simple strategy class in Objective-C that allows for
I am trying to implement a very simple little dropdown-style mini-menu that will appear
I am trying to implement a very basic before advice with Spring.Net, that just
I'm trying to implement a very, very simple accessibility test for Swing so I
I am very interested in at least trying to implement NAT break through for
I'm trying to decide how to implement a very basic licensing solution for some
I am trying to implement a simple code tester : a very basic version
This is a very basic example of what I am trying to implement in

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.