How to stub HttpRequestBase to return cookies?

瀏覽次數:79 次
跳到第一則未讀訊息

Scott McFadden

未讀,
2015年1月2日 晚上8:08:032015/1/2
收件者:rhino...@googlegroups.com
How do you stub HttpRequestBase to return cookies?  I get NotSupportedException when running test.

 var cookies = new HttpCookieCollection();
            
 var request = MockRepository.GenerateStub<HttpRequestBase>();
            
 request.Stub(x => x.Cookies).Return(cookies);  //NotSupportedException - Can't create mocks of sealed classes

.NET 3.51
RhinoMocks 3.61


           

Reginald Blue

未讀,
2015年1月5日 上午8:45:552015/1/5
收件者:rhino...@googlegroups.com

There must be something strange in your project. I just tried the exact same thing and it worked perfectly.

It was. Net 4.0 RhinoMocks 3.6, but that shouldn't matter. Start a blank project and try again.

--
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rhinomocks+...@googlegroups.com.
To post to this group, send email to rhino...@googlegroups.com.
Visit this group at http://groups.google.com/group/rhinomocks.
For more options, visit https://groups.google.com/d/optout.
回覆所有人
回覆作者
轉寄
0 則新訊息