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); }
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)); }
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); }
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); }
public void ManagerTearDown() { this.userProvider = null; this.server = null; this.handler = null; this.userManager = null; this.provider = null; this.context = null; }
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; }