How do you mock the session object collection using Moq

前端 未结 7 630
忘了有多久
忘了有多久 2020-11-28 22:08

I am using shanselmann\'s MvcMockHelper class to mock up some HttpContext stuff using Moq but the issue I am having is being able to assign something to my mocked session ob

7条回答
  •  时光取名叫无心
    2020-11-28 22:30

    I think you can set an expectation on the mock with a specific value it should return whatever. Mocks are not used as actual fakes but rather things that you can assert behavior on.

    It sounds like you are actually looking for an adapter that you can wrap around the session that you can supply a different implementation during tests and during runtime it would return HttpContext Session items?

    Does this make sense?

提交回复
热议问题