Пример #1
0
 public AutoShuffle(Game game, Notifier notifier)
 {
     _game = game;
     _game.GameStateChanged += Game_GameStateChanged;
     _notifier     = notifier;
     _roleAssigner = new RoleAssigner();
 }
Пример #2
0
		public void Correctly_assigns_current_user_to_role()
		{
			MockRepository mocks = new MockRepository();

			IPrincipal principal = mocks.CreateMock<IPrincipal>();
			IIdentity identity = mocks.CreateMock<IIdentity>();
			IWebContext context = mocks.CreateMock<IWebContext>();
			IPrincipalFactory principalFactory = mocks.CreateMock<IPrincipalFactory>();

			using (mocks.Record())
			{
				Expect.Call(context.GetUserIdentity()).Return(identity);
				Expect.Call(principalFactory.CreatePrincipal(identity, "Administrator", "Other Role")).Return(principal);
				context.SetUser(principal);
			}

			mocks.ReplayAll();

			using (mocks.Playback())
			{
				IRoleAssigner assigner = new RoleAssigner(context, principalFactory);
				assigner.AssignCurrentUserToRoles("Administrator", "Other Role");
			}

			mocks.VerifyAll();
		}
Пример #3
0
        public void Correctly_assigns_current_user_to_role()
        {
            MockRepository mocks = new MockRepository();

            IPrincipal        principal        = mocks.CreateMock <IPrincipal>();
            IIdentity         identity         = mocks.CreateMock <IIdentity>();
            IWebContext       context          = mocks.CreateMock <IWebContext>();
            IPrincipalFactory principalFactory = mocks.CreateMock <IPrincipalFactory>();

            using (mocks.Record())
            {
                Expect.Call(context.GetUserIdentity()).Return(identity);
                Expect.Call(principalFactory.CreatePrincipal(identity, "Administrator", "Other Role")).Return(principal);
                context.SetUser(principal);
            }

            mocks.ReplayAll();

            using (mocks.Playback())
            {
                IRoleAssigner assigner = new RoleAssigner(context, principalFactory);
                assigner.AssignCurrentUserToRoles("Administrator", "Other Role");
            }

            mocks.VerifyAll();
        }