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
I realize that it may be a bad idea, but has anyone had success mocking HttpContext?

When I run the following code:
HttpContext mockHttpContext = (HttpContext)RecorderManager.CreateMockedObject(typeof(HttpContext));

I get the following exception:
failed: System.Reflection.AmbiguousMatchException : Ambiguous match found.
at System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, Object& state)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TypeMock.MockManager.MockObject(Type type, Object[] args)
at TypeMock.RecorderManager.CreateMockedObject(Type typeToMock)

Any ideas?

- Michael
asked by adoptableCoho (1.2k points)

2 Answers

0 votes
Here is a link to Adrian Spear blog about mocking HttpContext.
Although you may have found a bug in our default constructor feature.
answered by scott (32k points)
0 votes
Hi
A patch was created and sent offline.
answered by ohad (35.4k points)
...