public void GlobalUser_GetUsers() { //static method calls List <GlobalUser> oNewUsers; List <GlobalUser> oUsers; WebCallResult res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 10); Assert.IsTrue(res.Success, "Failed to fetch global users"); Assert.IsTrue(oUsers.Count > 0, "No global users returned on fetch"); //exercise dump calls Console.WriteLine(oUsers[0].ToString()); Console.WriteLine(oUsers[0].DumpAllProps()); //GetUsers res = GlobalUser.GetUsers(null, out oNewUsers); Assert.IsFalse(res.Success, "Fetching users via static method with null ConnectionServerRest did not fail"); res = GlobalUser.GetUsers(_connectionServer, out oNewUsers, "query=(bogus)", "", "sort=(bogus)"); Assert.IsFalse(res.Success, "Fetching users via static method with invalid query construction did not fail"); string strQuery = string.Format("query=(Alias is {0})", oUsers[0].Alias); res = GlobalUser.GetUsers(_connectionServer, out oNewUsers, strQuery); Assert.IsTrue(res.Success, "Fetching users via static method with valid alias query construction failed"); Assert.IsTrue(oNewUsers.Count == 1, "Fetching users by alias construction did not return single match"); res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 20, "query=(ObjectId is Bogus)"); Assert.IsTrue(res.Success, "fetching users with invalid query should not fail:" + res); Assert.IsTrue(oUsers.Count == 0, "Invalid query string should return an empty user list:" + oUsers.Count); }
public void GetUsers_NullConnectionServer_EmptyClause_Failure() { List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(null, out oUsers, 1, 10, ""); Assert.IsFalse(res.Success, "Calling GetUsers with null Connection server should fail"); }
public void GlobalUser_GetUser() { GlobalUser oNewUser; List <GlobalUser> oUsers; WebCallResult res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 10); Assert.IsTrue(res.Success, "Failed to fetch global users"); Assert.IsTrue(oUsers.Count > 0, "No global users returned on fetch"); //GetUser res = GlobalUser.GetUser(out oNewUser, _connectionServer, ""); Assert.IsFalse(res.Success, "Fetching user with static method with empty objectId did not fail"); res = GlobalUser.GetUser(out oNewUser, null, "bogus"); Assert.IsFalse(res.Success, "Fetching user with static method with null Connection server did not fail"); res = GlobalUser.GetUser(out oNewUser, _connectionServer, "bogus"); Assert.IsFalse(res.Success, "Fetching user with static method with invalid objectId did not fail"); res = GlobalUser.GetUser(out oNewUser, _connectionServer, oUsers[0].ObjectId); Assert.IsTrue(res.Success, "Failed to fetch a user by valid ObjectId:" + res); res = GlobalUser.GetUser(out oNewUser, _connectionServer, "", oUsers[0].Alias); Assert.IsTrue(res.Success, "Failed to fetch a user by valid Alias:" + res); }
public void GlobalUser_Test() { _errorString = ""; List <GlobalUser> oGlobalUsers; var res = GlobalUser.GetUsers(_connectionServer, out oGlobalUsers, 1, 2); Assert.IsTrue(res.Success, "Failed to fetch global users:" + res); Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for global users:" + _errorString); }
public void GetUser_ErrorResponse_Failure() { Reset(); //error response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = false, ResponseText = "error text", StatusCode = 404 }); List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(_mockServer, out oUsers); Assert.IsFalse(res.Success, "Calling GetUser with error response did not fail"); }
public void GetUsers_GarbageResult_Failure() { Reset(); //garbage response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, TotalObjectCount = 1, ResponseText = "garbage result in the response body that will not parse properly to globalUser" }); List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(_mockServer, out oUsers); Assert.IsFalse(res.Success, "Calling GetUsers with garbage result did not fail"); }
public void GetUsers_EmptyResult_Failure() { Reset(); //empty results _mockTransport.Setup( x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "" }); List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(_mockServer, out oUsers); Assert.IsFalse(res.Success, "Calling GetUsers with EmptyResultText did not fail"); }
public void GetUsers_ZeroResults_Success() { Reset(); //zero results _mockTransport.Setup( x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, TotalObjectCount = 0, ResponseText = "junk" }); List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(_mockServer, out oUsers); Assert.IsTrue(res.Success, "Calling GetUsers with zero results failed:" + res); Assert.IsTrue(oUsers.Count == 0, "Callling GetUsers with zero results should return empty list."); }