It is currently Fri Jul 25, 2014 3:38 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jul 28, 2009 2:39 pm 
Offline
Newbie
Newbie

Joined: Thu Jan 15, 2009 7:43 pm
Posts: 6
From the Isolator documentation, I saw how to check if a private method was called using c#:
Code:
[TestMethod]
[Isolated]
public void StubPrivateMethod()
{
    RealLogger fake = Isolate.Fake.Instance<RealLogger>();

    // Avoid performing actual write to disk by ignoring (stubbing) a private call
    Isolate.NonPublic.WhenCalled(fake, "WriteToDisk").IgnoreCall();

    // This call is faked - count should not increment
    fake.Log("Hello World");

    Assert.AreEqual(1, fake.LineCount);
    // Verify the private call was actually made
    Isolate.Verify.NonPublic.WasCalled(fake, "WriteToDisk").WithArguments("Hello World");
}

How do I do this using VB syntax? I didn't see anything like that in the VB docs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 29, 2009 8:55 am 
Offline
Site Admin
Site Admin

Joined: Sat Mar 15, 2008 9:36 am
Posts: 405
Hi,

You should use NonPublicWillBeIgnored() and its sister methods (NonPublicWillReturn, NonPublicWillCallOriginal, NonPublicWillThrow etc.).

I will make sure we update our docs for a future version.

Thanks,
Doron
Typemock Support


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 29, 2009 2:30 pm 
Offline
Newbie
Newbie

Joined: Thu Jan 15, 2009 7:43 pm
Posts: 6
Using these 3 methods change the behavior of the call. How would I verify that a private method is called?

So the VB equivalent of this:
Code:
// Verify the private call was actually made
    Isolate.Verify.NonPublic.WasCalled(fake, "WriteToDisk").WithArguments("Hello World");

I don't see a method that would be able to be used in the VB:
Code:
Using AssertCalls.HappenedWithExactArguments
    fake.WriteToDisk("Hello World") 'compiler error
End Using

On the other hand, how do you verify a private method was NOT called
Code:
Using AssertCalls.NeverHappened
    fake.WriteToDisk("Hello World") 'compiler error
End Using


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group