public void TestGetRegisteredUsers() { UserCache userCache = null; try { userCache = new UserCache(); List<User> userList = new List<User>(userCache.GetRegisteredUsers()); Assert.That(userList.Count, NUnit.Framework.Is.EqualTo(0)); string username1 = "user1"; string hostname1 = username1 + "-ws"; string username2 = "user2"; string hostname2 = string.Empty; RegistrationRequest request1 = new RegistrationRequest(hostname1, username1); RegistrationRequest request2 = new RegistrationRequest(hostname2, username2); userCache.Register(request1); userCache.Register(request2); userList = new List<User>(userCache.GetRegisteredUsers()); Assert.That(userList.Count, NUnit.Framework.Is.EqualTo(1)); User user = userList[0]; Assert.That(user.Hostname, NUnit.Framework.Is.EqualTo(hostname1)); Assert.That(user.Username, NUnit.Framework.Is.EqualTo(username1)); } finally { if (userCache != null) { userCache.Dispose(); } } }
public void TestRegistrationUpdateEvent() { UserCache userCache = null; try { userCache = new UserCache(); User user = null; userCache.OnUpdate += delegate(object sender, EventArgs args) { user = (User)sender; }; string username = "******"; string hostname = username + "-ws"; RegistrationRequest request = new RegistrationRequest(hostname, username); userCache.Register(request); Assert.That(user, NUnit.Framework.Is.Not.Null); Assert.That(user.Username, NUnit.Framework.Is.EqualTo(username)); Assert.That(user.Hostname, NUnit.Framework.Is.EqualTo(hostname)); Assert.That(user.ActiveBuilds.Count, NUnit.Framework.Is.EqualTo(0)); Assert.That(user.BuildsResponsibleFor.Count, NUnit.Framework.Is.EqualTo(0)); } finally { if (userCache != null) { userCache.Dispose(); } } }