Exemplo n.º 1
0
 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"));
     }
 }
Exemplo n.º 2
0
        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();
        }