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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:51:14+00:00 2026-05-11T14:51:14+00:00

I’m trying to test a method. I want to ensrur that there is a

  • 0

I’m trying to test a method. I want to ensrur that there is a method call in that method (calling service) the code look like this:

using(proxy = new Proxy()) {        proxy.CallService(); } 

I swap the proxy with fake object (using TypeMock) but get error because of the fake object disposed in the end of block. I don’t want to remove that ‘using’ block. Thanks

  • 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. 2026-05-11T14:51:14+00:00Added an answer on May 11, 2026 at 2:51 pm

    Disclaimer: I work at Typemock
    If you are using the Arrange Act Assert API you can use Members.ReturnRecursiveFakes when you are creating your fake object (Note: this is the default from version 5.2.0) This will automatically fake the Dispose method as well.

    so your test will be something like this:

    var fake = Isolate.Fake.Instance<Proxy>(Members.ReturnRecursiveFakes); Isolate.WhenCalled(() => fake.CallService()).IgnoreCall(); Isolate.Swap.NextInstance<Proxy>().With(fake);  UnderTest classUnderTest = new ClassUnderTest(); classUnderTest.MethodUnderTest(); // assuming the Proxy instance is used here.  Isolate.Verify.WasCalledWithAnyArguments(()=>fake.CallService()); 

    I want to add to what Jon Skeet said that I would create a separate test that will ensure that the Dispose method is called.
    I think it is a good practice to assert one thing in each test method, that way when a test breaks up you’ll know the reason immediately.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post

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.