public void When_Creating_User_Then_User_Can_Login() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("Henry", "hunter2"); _business.CreateUser("Bobby", "IOnlySee*******"); Assert.IsTrue(_business.Connect("Henry", "hunter2")); Assert.IsTrue(_business.Connect("Bobby", "IOnlySee*******")); }
public void When_Double_Invite_Is_Sent_Then_Only_One_Is_Kept() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); var notifs = _business.GetNotification("noSoyElAdmin"); Assert.IsTrue(notifs.Count == 1); }
public void When_Changing_Group_Admin_Then_Rights_Are_Swapped() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.AcknowledgeInvite("noSoyElAdmin", "LosBanditos", true); Assert.AreEqual("soyElAdmin", _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos")?.Administrator.Name); _business.ChangeAdministratorGroup("soyElAdmin", "noSoyElAdmin", "LosBanditos"); Assert.AreEqual("noSoyElAdmin", _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos")?.Administrator.Name); }
public void When_Request_Is_Sent_Then_Admin_Has_Notification() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupRequest("noSoyElAdmin", "LosBanditos"); var notifs = _business.GetNotification("soyElAdmin"); Assert.IsTrue(notifs.Count == 1); Assert.IsTrue(notifs.FirstOrDefault()?.ActionType == ActionType.Request); Assert.IsTrue(notifs.FirstOrDefault()?.ClientName == "noSoyElAdmin"); Assert.IsTrue(notifs.FirstOrDefault()?.GroupName == "LosBanditos"); }
public void When_Creating_Group_Then_You_Are_Admin_And_Member() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("potato", "potàto"); _business.CreateGroup("FrenchFries", "Fried batons of potato", "potato"); Assert.AreEqual("potato", _business.GetGroupList().FirstOrDefault(g => g.Name == "FrenchFries")?.Administrator.Name); Assert.IsTrue(_business.GetGroupList().FirstOrDefault(g => g.Name == "FrenchFries")?.Members.Exists(m => m.Name == "potato") == true); }
public void When_Admin_Kicks_User_Then_User_Is_Removed() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.AcknowledgeInvite("noSoyElAdmin", "LosBanditos", true); var group = _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos"); Assert.IsTrue(group?.Members.Count == 2); _business.KickUserFromGroup("soyElAdmin", "noSoyElAdmin", "LosBanditos"); Assert.IsTrue(group.Members.Count == 1); Assert.IsTrue(_business.GetGroupListForClient("noSoyElAdmin").Count == 0); }
public void When_Invite_Is_Sent_Then_Admin_Can_Reply() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupRequest("noSoyElAdmin", "LosBanditos"); var notif = _business.GetNotification("soyElAdmin").FirstOrDefault(); _business.AcknowledgeRequest("soyElAdmin", notif?.ClientName, notif?.GroupName, true); var groupsForClient = _business.GetGroupListForClient(notif?.ClientName); Assert.IsTrue(groupsForClient.Count == 1); var group = groupsForClient.FirstOrDefault(); Assert.IsTrue(group != null && group.Members.Exists(m => m.Name == notif?.ClientName)); }
public void SetUp() { // Delete last test data string rootPath = "Server Root Test"; if (Directory.Exists(rootPath)) { Directory.Delete(rootPath, true); } business = new ServerBusiness("groupSave", "clientSave", rootPath); business.CreateUser("Bob", "psw"); business.CreateGroup("A", "Desc", "Bob"); }