Esempio n. 1
0
 private static void CreateUsers(IClientConnection client, ClientUserHandler handler)
 {
     handler.OnUserListReceivedMessage(new MessageEventArgs <UserInfoListMessage> (client,
                                                                                   new UserInfoListMessage(new[]
     {
         new UserInfo("Foo", "Foo", 1, 1, false),
         new UserInfo("Bar", "Bar", 2, 1, false),
         new UserInfo("Wee", "Wee", 3, 2, true),
     })));
     Assert.AreEqual(3, handler.Count());
     VerifyDefaultUsers(handler);
 }
Esempio n. 2
0
        public void ApproveRegistrationUnsupported()
        {
            userProvider.UpdateSupported  = false;
            userProvider.RegistrationMode = UserRegistrationMode.None;
            context = new MockClientContext(this.client)
            {
                ServerInfo = new ServerInfo(new ServerSettings(), userProvider)
            };
            this.handler = new ClientUserHandler(context, this.userManager);

            CreateUsers(this.client, this.handler);

            var user = this.handler.First();

            Assert.Throws <NotSupportedException>(() => this.handler.ApproveRegistration(user));
        }
Esempio n. 3
0
        public void ApproveRegistration()
        {
            userProvider.UpdateSupported  = true;
            userProvider.RegistrationMode = UserRegistrationMode.Approved;
            context = new MockClientContext(this.client)
            {
                ServerInfo = new ServerInfo(new ServerSettings(), userProvider)
            };
            this.handler = new ClientUserHandler(context, this.userManager);

            this.handler.ApproveRegistration("username");

            var msg = this.server.DequeueAndAssertMessage <RegistrationApprovalMessage>();

            Assert.AreEqual("username", msg.Username);
        }
Esempio n. 4
0
        public void PreApproveRegistration()
        {
            userProvider.UpdateSupported  = true;
            userProvider.RegistrationMode = UserRegistrationMode.PreApproved;
            context = new MockClientContext(this.client)
            {
                ServerInfo = new ServerInfo(new ServerSettings(), userProvider)
            };
            this.handler = new ClientUserHandler(context, this.userManager);

            CreateUsers(this.client, this.handler);

            var user   = this.handler.First();
            int userId = user.UserId;

            this.handler.ApproveRegistration(user);

            var msg = this.server.DequeueAndAssertMessage <RegistrationApprovalMessage>();

            Assert.AreEqual(userId, msg.UserId);
        }