public void Does_not_set_current_user_in_context_if_one_is_not_logged_in()
        {
            MockRepository mocks   = new MockRepository();
            IWebContext    context = mocks.CreateMock <IWebContext>();

            using (mocks.Record())
            {
                Expect.Call(context.GetUserIdentity()).Return(null);
            }

            using (mocks.Playback())
            {
                ISystemUserContextManager manager = new SystemUserContextManager(context, null);
                manager.SetUserContext();
            }

            mocks.VerifyAll();
        }
        public void Correctly_sets_current_user_in_web_context()
        {
            MockRepository        mocks        = new MockRepository();
            IWebContext           context      = mocks.CreateMock <IWebContext>();
            IIdentity             userIdentity = mocks.CreateMock <IIdentity>();
            ISystemUserRepository repository   = mocks.CreateMock <ISystemUserRepository>();
            ISystemUser           user         = mocks.CreateMock <ISystemUser>();

            using (mocks.Record())
            {
                Expect.Call(context.GetUserIdentity()).Return(userIdentity);
                Expect.Call(userIdentity.Name).Return("*****@*****.**");
                Expect.Call(repository.GetByEmailAddress("*****@*****.**")).Return(user);
                context.SetItem(SystemUserContextManager.CURRENT_USER, user);
            }

            using (mocks.Playback())
            {
                ISystemUserContextManager manager = new SystemUserContextManager(context, repository);
                manager.SetUserContext();
            }

            mocks.VerifyAll();
        }