:arrow: When you use
MockManager.Mock you are actually telling TypeMock to wait for the next time an
HttpFileCollection is created, and when it is created it will be mocked. This is handy if an
HttpFileCollection is created somewhere in the tested code.
:idea: To create a mocked instance of
HttpFileCollection simply use:
MockManager.MockObject()
you can then use the
Object property to get the actual object.
<Test(),VerifyMocks()> Public Sub Test()
Dim anUploadedFilesValidator As IUploadedFilesValidator
anUploadedFilesValidator = New UploadedFilesValidator
anUploadedFilesValidator.MaximumFiles = 10
Dim httpFileCollectionMock As TypeMock.MockObject (Of HttpFileCollection) = TypeMock.MockManager.MockObject( Of System.Web.HttpFileCollection))
httpFileCollectionMock.ExpectGet("Count", 9)
Assert.That(anUploadedFilesValidator.IsValid(httpFileCollectionMock.Object), [Is].True)