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 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)); }
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 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); }