Inheritance: IClientUserHandler
Esempio n. 1
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. 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
 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. 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);
        }
Esempio n. 5
0
 public void ManagerTearDown()
 {
     this.userProvider = null;
     this.server = null;
     this.handler = null;
     this.userManager = null;
     this.provider = null;
     this.context = null;
 }
Esempio n. 6
0
        public void ManagerSetup()
        {
            this.provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            this.provider.Start (MessageTypes.All);

            var connections = this.provider.GetConnections (GablarskiProtocol.Instance);

            this.server = new ConnectionBuffer (connections.Item2);
            this.client = connections.Item1;

            userProvider = new MockUserProvider();
            context = new MockClientContext (client) { ServerInfo = new ServerInfo (new ServerSettings(), userProvider) };

            var channels = new ClientChannelManager (context);
            ClientChannelManagerTests.PopulateChannels (channels, this.server);

            this.userManager = new ClientUserManager();
            this.handler = new ClientUserHandler (context, userManager);
            context.Users = this.handler;
            context.Channels = channels;
        }