Hi,
I am not proficient with VB, but I believe this is due to late binding
as described here:
https://stackoverflow.com/a/48936317/906.
The solution is to explicitly call the `Returns` extension method
whenever you have a reference to type `Object` so that late-binding is
not used:
<TestMethod()> Public Sub Session_Should_Have_Item()
Dim httpContext = Substitute.[For](Of HttpContextBase)()
Dim expected = 1008
SubstituteExtensions.Returns(httpContext.Session("RoleId"), expected)
Dim actual = httpContext.Session("RoleId")
Assert.AreEqual(expected, actual)
End Sub
This can be made a little simpler with aliases: `Imports NSub =
NSubstitute.SubstituteExtensions`, then `NSub.Returns(...)`. As far as
I can tell this should only be required when you have a reference to a
`System.Object`.
NSubstitute's syntax was tailored for C# and can sometimes be a bit
clunky in VB, but it doesn't specifically parse the VB or C# code (it
just works from the compiled .NET DLL) so it should not be a problem
from that perspective.
Regards,
David
> --
> You received this message because you are subscribed to the Google Groups "NSubstitute" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
nsubstitute...@googlegroups.com.
> To post to this group, send email to
nsubs...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/nsubstitute.
> For more options, visit
https://groups.google.com/d/optout.