public int addStore(string name, int rank, int ownerId) { Member owner = ConnectionStubTemp.getMember(ownerId); int ret = WorkShop.createNewStore(name, rank, true, owner); return(ret); }
public void RemoveUser_test() { try { Init(); Store s = new Store(1, "store", 1, true); member.addStore(s); admin.RemoveUser("username"); try { ConnectionStubTemp.getMember("username"); Assert.IsTrue(false); } catch (Exception ex) { Assert.IsTrue(true); } } finally { Cleanup(); } }
public static User getUser(string username, string password) { int userId = ConnectionStubTemp.identifyUser(username, password); User user = ConnectionStubTemp.getMember(userId); return(user); }
public void OwnershiprequestJust1_test() { Init(); ConnectionStubTemp.createOwnershipRequest(store, firstStoreOwner, SecondStoreOwner); Assert.IsTrue(SecondStoreOwner.isStoresOwner(storeId)); Cealup(); }
public bool removeMember(int memberId) { string username = ConnectionStubTemp.GetMemberById(memberId).username; ConnectionStubTemp.Remove(memberId); //ConnectionStubTemp.mapIDUsermane.Remove(username); return(true); }
public bool removeStore(int storeId, int ownerId) { Member owner = ConnectionStubTemp.getMember(ownerId); WorkShop.closeStore(storeId, owner); WorkShop.Remove(storeId); return(true); }
/**STUB**/ public static void clearStub() { Stores.Delete(); Passwords.Delete(); OwnershipRequests.Delete(); Members.Delete(); ConnectionStubTemp.init(); }
public bool appointUserToStoreOwnership(int storeId, int newOwnerId, int storeOwnerId) { Store store = WorkShop.getStore(storeId); Member owner = ConnectionStubTemp.getMember(storeOwnerId); Member newowner = ConnectionStubTemp.getMember(storeOwnerId); Roles role = new Roles(true, true, true, true, true, true, true, true, true); owner.addManager(newowner.username, role, store); return(true); }
public void Init() { god = new GodObject(); god.clearDb(); User user = new User(); user.registerNewUser("hadas", "ss", DateTime.Today.AddYears(-25), "A"); storeOwner = ConnectionStubTemp.GetMemberByName("hadas"); idStore = WorkShop.createNewStore("TestPolicyStore", 10, true, storeOwner); store = WorkShop.getStore(idStore); }
//[TestInitialize] public void Init() { DataAccessDriver.UseStub = true; ownerId = god.addMember("username", "password"); storeId = god.addStore("store name", 1, ownerId); store = WorkShop.getStore(storeId); storeOwner = ConnectionStubTemp.getMember(ownerId); int someMemberId = god.addMember("some member", "some password"); someMember = ConnectionStubTemp.getMember(someMemberId); }
//NOT FOR LOGIN PROXY!! public static void MakeAdmin(int memberId) { Member member = ConnectionStubTemp.getMember(memberId); Password.Password passOrig = ConnectionStubTemp.pHandler.GetPasswordForMember(memberId); Password.Password passCopy = new Password.Password(passOrig); SystemAdmin newsys = new SystemAdmin(member); ConnectionStubTemp.removeMember(member); ConnectionStubTemp.addMemberJustForExternalUsage(newsys, new Password.Password(passCopy)); }
public void Cleanup() { try { m = ConnectionStubTemp.getMember(username); ConnectionStubTemp.removeMember(m); } catch (Exception ex)//not registerd { } DataAccessDriver.UseStub = false; }
public void Init() { ownerId = god.addMember("username", "password"); ownerId2 = god.addMember("some member", "some password"); storeOwner = ConnectionStubTemp.getMember(ownerId); someMember = ConnectionStubTemp.getMember(ownerId2); ownerRoles = new Roles(true, true, true, true, true, true, true, true); storeId = WorkShop.createNewStore("best shop", 1, true, storeOwner); store = WorkShop.getStore(storeId); }
public int addMember(string username, string password) { Member member = ConnectionStubTemp.registerNewUser(username, password, DateTime.Today.AddYears(1), ""); if (member == null) { return(-1); } return(member.id); //return ConnectionStubTemp.memberIDGenerator - 1; }
//[TestCleanup] public void Cealup() { try { ConnectionStubTemp.getMember(username + "1"); ConnectionStubTemp.removeMember(member1); ConnectionStubTemp.getMember(username + "2"); ConnectionStubTemp.removeMember(member2); } catch (Exception ex)//not registerd { } DataAccessDriver.UseStub = false; }
//[TestInitialize] public void Init() { ownerId1 = god.addMember("username1_TestStoreManager", "password1"); ownerId2 = god.addMember("username2_TestStoreManager", "password2"); ownerId3 = god.addMember("username3_TestStoreManager", "password3"); ownerId4 = god.addMember("username4_TestStoreManager", "password4"); firstStoreOwner = ConnectionStubTemp.getMember(ownerId1); SecondStoreOwner = ConnectionStubTemp.getMember(ownerId2); ThirdStoreOwner = ConnectionStubTemp.getMember(ownerId3); LastStoreOwner = ConnectionStubTemp.getMember(ownerId4); storeId = WorkShop.createNewStore("best shop", 1, true, firstStoreOwner); store = WorkShop.getStore(storeId); }
public bool removeMember(string member) { int id; Member m = ConnectionStubTemp.GetMemberByName(member); if (m != null) { ConnectionStubTemp.Remove(m.id); return(true); } return(false); //bool ret = ConnectionStubTemp.mapIDUsermane.TryGetValue(member, out id); //ConnectionStubTemp.Remove(member); //ConnectionStubTemp.Remove(id); //return ret; }
public void makeAdminTest() { string userName = "******"; addUser(userName); string command = $"{make_admin}({userName})"; string[] splitedCommand = InitSystem.splitCommand(command); InitSystem.makeAdmin(splitedCommand); User user = InitSystem.getUser(userName, userPass); Assert.IsTrue(user is SystemAdmin); ConnectionStubTemp.removeAdmin((SystemAdmin)user); }
//[TestCleanup] public void Cealup() { god.removeStore(storeId, ownerId); god.removeMember(ownerId); god.removeMember(ownerId2); god.removeMember(managerId); god.removeMember(managerId2); try { ConnectionStubTemp.removeMember(storeOwner); ConnectionStubTemp.removeMember(storeOwner2); ConnectionStubTemp.removeMember(storeManager); ConnectionStubTemp.removeMember(storeManager2); } catch (Exception ex) { } DataAccessDriver.UseStub = true; }
//[TestInitialize] public void Init() { DataAccessDriver.UseStub = true; ownerId = god.addMember("username1", "password1"); ownerId2 = god.addMember("username2", "password2"); managerId = god.addMember("username3", "password3"); managerId2 = god.addMember("username4", "password4"); storeOwner = ConnectionStubTemp.getMember(ownerId); storeOwner2 = ConnectionStubTemp.getMember(ownerId2); storeManager = ConnectionStubTemp.getMember(managerId); storeManager2 = ConnectionStubTemp.getMember(managerId2); ownerRoles = new Roles(true, true, true, true, true, true, true, true, true); managerRoles = new Roles(true, true, true, true, true, false, false, false, true); storeId = WorkShop.createNewStore("best shop", 1, true, storeOwner); store = WorkShop.getStore(storeId); }
public void OwnershiprequestmoreThan1_test() { Init(); int requestId1, requestId2; ConnectionStubTemp.createOwnershipRequest(store, firstStoreOwner, SecondStoreOwner); Assert.IsTrue(SecondStoreOwner.isStoresOwner(storeId)); requestId1 = ConnectionStubTemp.createOwnershipRequest(store, firstStoreOwner, ThirdStoreOwner); SecondStoreOwner.approveOwnershipRequest(requestId1); Assert.IsTrue(ThirdStoreOwner.isStoresOwner(storeId)); requestId2 = requestId1 = ConnectionStubTemp.createOwnershipRequest(store, ThirdStoreOwner, LastStoreOwner); firstStoreOwner.approveOwnershipRequest(requestId2); SecondStoreOwner.approveOwnershipRequest(requestId2); Assert.IsTrue(LastStoreOwner.isStoresOwner(storeId)); Cealup(); }
public void registerNewUser_Test() { try { Init(); user.registerNewUser(username, password, DateTime.Now, "shit"); Assert.IsTrue(true); try { m = ConnectionStubTemp.getMember(username); Assert.IsTrue(true); } catch (Exception ex)//didnt worked { Assert.IsTrue(false); } } finally { Cleanup(); } }
public bool removeManagerFromStore(int storeId, int ManagerId) { Member member = ConnectionStubTemp.GetMemberById(ManagerId); LinkedList <StoreManager> storeManagers = member.storeManaging; foreach (StoreManager sm in storeManagers) { if (sm.GetStore().id == storeId) { if (sm.GetFather() == null) { WorkShop.closeStore(storeId, member); } else { sm.GetFather().removeManager(sm); } return(true); } } return(false); }
public bool makeUserManager(int storeId, int storeOwnerId, int newManagerId, bool[] roles) { Roles newRoles = new Roles(roles[0], roles[1], roles[2], roles[3], roles[4], roles[5], roles[6], roles[7], roles[8]); Store store = WorkShop.getStore(storeId); Member storeOwner = ConnectionStubTemp.GetMemberById(storeOwnerId); Member newManager = ConnectionStubTemp.GetMemberById(newManagerId); LinkedList <StoreManager> nmstoreManagers = newManager.storeManaging; StoreManager newStoreManager = new StoreManager(store, newRoles); nmstoreManagers.AddFirst(newStoreManager); LinkedList <StoreManager> storeManagers = storeOwner.storeManaging; foreach (StoreManager sm in storeManagers) { if (sm.GetStore().id == storeId) { sm.subManagers.AddFirst(newStoreManager); return(true); } } return(false); }
/*about roles: the client will choose what roles he wants to give the new * manager (needs to be like hes and below) */ public bool CreateNewManager(Member member, Roles roles) { if (!checkNotAManager(member)) { Logger.Log("error", logLevel.INFO, "store:" + store.id + " failed add new manager beacuae he is already a manager: " + member.username); throw new Exception("this member is already manager of this store"); } else if (this.storeOwner || myRoles.CompareRoles(roles)) { StoreManager newSubStoreManager = new StoreManager(this.store, roles); newSubStoreManager.setFather(this); subManagers.AddFirst(newSubStoreManager); member.addStoreToMe(newSubStoreManager); Logger.Log("event", logLevel.INFO, "store:" + store.id + " succesfully add new manager: " + member.username); ConnectionStubTemp.Update(member);//SHIRA return(true); } else { Logger.Log("error", logLevel.INFO, "store:" + store.id + " failed add new manager: " + member.username); throw new Exception("this manager try to give more roles than he can"); } }
private void deleteUser(String userName) { User user = InitSystem.getUser(userName, userPass); ConnectionStubTemp.removeMember((Member)user); }
public static void SendMessage(int memberId, string message) { Member member = ConnectionStubTemp.getMember(memberId); member.addMessage(message); }
//int storeId; // Store store; //[TestInitialize] public void Init() { DataAccessDriver.UseStub = true; memberId = god.addMember("username", "password"); member = ConnectionStubTemp.getMember(memberId); }
public static List <Member> GetAllMembers() { //return ConnectionStubTemp.members.Values.ToList(); return(ConnectionStubTemp.GetMembers()); }