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
Hi there.

I have the following code snippet:

Controls.Add(New LiteralControl("<div id=""Links-Area"">"))


In my unit test, how can I do the following:

Using AssertCalls.HappenedWithExactArguments()
                fakeSeeAlso.Controls.Add(New LiteralControl("<div id=""Links-Area"">"))
            End Using


The above code does compile, but when I run the test, I get this error:

*** Assign Parameter Error, for System.Web.UI.LiteralControl..ctor.


Is it possible to assert on creating new objects via the Controls.Add() call?

Cheers.
Jas.
asked by MrClyfar (5.2k points)

1 Answer

0 votes
Hi Jas,

The reason that the code you've used didn't work is because Isolator do not handle call inside call - in the example you have a call to thhe class constructor inside a call to Add

Instead try changing you code to look like:
dim newLiteral as New LiteralControl("<div id=""Links-Area"">")
Using AssertCalls.HappenedWithExactArguments() 
         Controls.Add(newLiteral)
End Using


Another point worth mentioning is that for the AssertCalls.WithExactArguments to pass the new Literal should be equal to the actual parameter passed in our code.
answered by dhelper (11.9k points)
...