public void Can_Mock_UnitTest_Session_in_IOC_with_MockHttpRequest() { using (new BasicAppHost { ConfigureContainer = container => container.Register <IAuthSession>(c => CreateUserSession()) }.Init()) { var service = new SessionService { Request = new MockHttpRequest() }; var session = service.GetSession(); Assert.That(session.UserAuthId, Is.EqualTo("1")); Assert.That(session.UserAuthName, Is.EqualTo("Mocked")); } }
public void Can_mock_UnitTest_Session_with_IOC() { var appHost = new BasicAppHost { TestMode = true, ConfigureContainer = container => { container.Register <IAuthSession>(c => new AuthUserSession { UserName = "******", }); } }.Init(); var service = new SessionService { Request = new MockHttpRequest() }; Assert.That(service.GetSession().UserName, Is.EqualTo("Mocked")); appHost.Dispose(); }