public void FetchAdminListTest_2() { int ExpectedRowCount = 0; int GotRowCount = -1; try { UserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetToken("abcdef12345"); UserTemplate <IUserProfile> AdminUserTemplate = new AdminUserTemplate(UserProfileObj); List <IUserProfile> Output = AdminUserTemplate.FetchList(); GotRowCount = Output.Count; } catch (Exception) { GotRowCount = -1; } Assert.AreEqual(ExpectedRowCount, GotRowCount); }
public void FetchAdminListTest_1() { ExpectedOutput = "Invalid Arguments : Token is null"; GotOutput = ""; try { IUserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetToken(null); UserTemplate <IUserProfile> AdminUserTemplate = new AdminUserTemplate(UserProfileObj); List <IUserProfile> Output = AdminUserTemplate.FetchList(); GotOutput = "SUCCESS"; } catch (Exception ex) { GotOutput = ex.Message.ToString(); } Assert.AreEqual(ExpectedOutput, GotOutput); }
public void RemoveAdmin_2() { IUserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetEmail(""); APIResponse ExpectedOutput = APIResponse.NOT_OK; APIResponse GotOutput = APIResponse.NOT_OK; try { UserTemplate <IUserProfile> AdminTemplate = new AdminUserTemplate(UserProfileObj); GotOutput = AdminTemplate.Remove(); } catch (Exception) { GotOutput = APIResponse.NOT_OK; } Assert.AreEqual(ExpectedOutput, GotOutput); }
public void RemoveAdmin_3() { IUserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetEmail("*****@*****.**"); APIResponse ExpectedOutput = APIResponse.OK; APIResponse GotOutput = APIResponse.NOT_OK; UserTemplate <IUserProfile> AdminTemplate = new AdminUserTemplate(UserProfileObj); try { GotOutput = AdminTemplate.Remove(); } catch (Exception) { GotOutput = APIResponse.NOT_OK; } // re-add the removed admin to admin AdminTemplate.Add(); Assert.AreEqual(ExpectedOutput, GotOutput); }
public void AddAdmin_3() { IUserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetEmail("*****@*****.**"); APIResponse ExpectedOutput = APIResponse.OK; APIResponse GotOutput = APIResponse.NOT_OK; UserTemplate <IUserProfile> AdminTemplate = new AdminUserTemplate(UserProfileObj); try { GotOutput = AdminTemplate.Add(); } catch (Exception) { GotOutput = APIResponse.NOT_OK; } Assert.AreEqual(ExpectedOutput, GotOutput); // remove the admin rights AdminTemplate.Remove(); }
public void FetchAdminListTest_3() { UserProfile UserProfileObj = new UserProfile(); UserProfileObj.SetEmail("*****@*****.**"); List <string> token = new SecurityDataLayer(UserProfileObj).GetTokenList(); if (token.Count == 0) { // token count = 0 means that the account is not logged in or all sessions destroyed // generate the token UserProfileObj.SetPassword("aA!12345"); // login the user new UserActions().LoginUserAction(UserProfileObj); token = new SecurityDataLayer(UserProfileObj).GetTokenList(); } UserProfileObj.SetToken(token[token.Count - 1].ToString()); UserTemplate <IUserProfile> AdminUserTemplate = new AdminUserTemplate(UserProfileObj); List <IUserProfile> Output = AdminUserTemplate.FetchList(); Assert.AreEqual(Output.Count > 0, true); }