chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
From the Isolator documentation, I saw how to check if a private method was called using c#:
[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.
asked by underwhelmed (1.7k points)

2 Answers

0 votes
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
answered by doron (17.2k points)
0 votes
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:
// 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:
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
Using AssertCalls.NeverHappened
    fake.WriteToDisk("Hello World") 'compiler error
End Using
answered by underwhelmed (1.7k points)
...