public void CreateJobListTest() { bool unicode = false; string server = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 2; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, unicode); try { using (P4Server target = new P4Server(server, user, pass, ws_client)) { //P4JobList expected = null; P4JobList actual; actual = new P4JobList(target); Assert.AreEqual(1, actual.Count); } } catch (Exception ex) { Assert.Fail("Exception Thrown: {0} : {1}", ex.ToString(), ex.Message); } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
//public void HASLogin(Repository repository) //{ // Repository = repository; // bool test = false; // P4Server p4Server = Repository.Connection.getP4Server(); // if (p4Server!=null) // { // test = p4Server.UrlHandled(); // } // Task<Credential> task = Task.Run<Credential>(async () => await AsyncLogin()); // Thread.Sleep(3000); // test = Repository.Connection.getP4Server().UrlHandled(); // if (test) // { // while(!task.IsCompleted) // { // ShowDialog(); // } // Close(); // } // return; //} public new DialogResult ShowDialog() { bool test = false; P4Server p4Server = Repository.Connection.getP4Server(); if (p4Server != null) { test = p4Server.UrlHandled(); } Task <Credential> task = Task.Run <Credential>(async() => await AsyncLogin()); Thread.Sleep(3000); test = Repository.Connection.getP4Server().UrlHandled(); if (test) { while (!task.IsCompleted) { base.ShowDialog(); } DialogResult = DialogResult.OK; base.Close(); return(DialogResult); } return(DialogResult.Cancel); }
public void FetchTest() { bool unicode = false; string server = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 2; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, unicode); try { using (P4Server target = new P4Server(server, user, pass, ws_client)) { P4User actual = P4User.Fetch(target, "admin"); Assert.IsNotNull(actual); Assert.AreEqual("admin", actual.User); } } catch (Exception ex) { Assert.Fail("Exception Thrown: {0} : {1}", ex.ToString(), ex.Message); } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
public void InsertTest1() { bool unicode = false; for (int i = 0; i < 2; i++) { using (P4Server pserver = new P4Server(unicode)) { using (P4MapApi target = new P4MapApi(pserver)) { string lr1 = "Both 1"; P4MapApi.Type type1 = P4MapApi.Type.Include; target.Insert(lr1, type1); string lr2 = "Both 2"; P4MapApi.Type type2 = P4MapApi.Type.Include; target.Insert(lr2, type2); int tCount = target.Count; Assert.AreEqual(2, tCount); // no errors so passed } } } }
public void ParseTest() { P4Server pserver = new P4Server(false); P4User target = new P4User(pserver, "fred"); // TODO: Initialize to an appropriate value target.Parse(spec); Assert.AreEqual(target.User, "fred"); }
public void PendingTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", "FredClient"); bool actual; actual = target.Pending; Assert.AreEqual(true, actual); // can only test default value of false }
private static void RestoreP4Prefs() { P4Bridge.ReloadEnviro(); for (int i = 0; i < settings.Length; i++) { P4Server.Set(settings[i], settingValues[i]); } }
public void ParseTest() { P4Server pserver = new P4Server(false); P4Workspace target = new P4Workspace(pserver, "temp"); bool actual = target.Parse(spec); Assert.IsTrue(actual); Assert.AreEqual(target.Name, "XP1_usr"); }
private void cmdThreadProc2() { try { P4Server server = serverMT.getServer(); while (run) { cmdCnt2++; cmd2 = new P4Command(server, "dirs", false, "//depot/*"); DateTime StartedAt = DateTime.Now; WriteLine(string.Format("Thread 2 starting command: {0:X8}, at {1}", cmd2.CommandId, StartedAt.ToLongTimeString())); P4CommandResult result = cmd2.Run(); WriteLine(string.Format("Thread 2 Finished command: {0:X8}, at {1}, run time {2} Milliseconds", cmd2.CommandId, StartedAt.ToLongTimeString(), (DateTime.Now - StartedAt).TotalMilliseconds)); P4CommandResult lastResult = server.LastResults; // Assert is not allowed on the non primary thread Assert.AreEqual(result.Success, lastResult.Success); if (!result.Success) { string msg = string.Format("Thread 2, fstat failed:{0}", (result.ErrorList != null && result.ErrorList.Count > 0) ? result.ErrorList[0].ErrorMessage : "<unknown error>"); WriteLine(msg); throw new Exception(msg); } else { WriteLine(string.Format("Thread 2, dirs Success:{0}", (result.InfoOutput != null && result.InfoOutput.Count > 0) ? result.InfoOutput[0].Message : "<no output>")); } //Assert.IsTrue(result.Success); if (delay != TimeSpan.Zero) { Thread.Sleep(delay); } } WriteLine(string.Format("Thread 2 cleanly exited after running {0} commands", cmdCnt2)); } catch (ThreadAbortException) { Thread.ResetAbort(); return; } catch (Exception ex) { WriteLine(string.Format("cmdThreadProc2 failed with exception: {0}\r\n{1}", ex.Message, ex.StackTrace)); runThreadExeptions.Add(new RunThreadException(2, ex)); //Assert.Fail("cmdThreadProc2 failed with exception", ex.Message); } }
public void ClientTest() { String expected = "FredClient"; P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", expected); string actual; actual = target.Client; Assert.AreEqual(expected, actual); }
public void JobViewTest() { P4Server pserver = null; P4User target = new P4User(pserver, "Fred"); string expected = "type=bug & ^status=closed"; string actual; target.JobView = expected; actual = target.JobView; Assert.AreEqual(expected, actual); }
public void EmailTest() { P4Server pserver = null; P4User target = new P4User(pserver, "Fred"); string expected = "*****@*****.**"; string actual; target.Email = expected; actual = target.Email; Assert.AreEqual(expected, actual); }
public void FullNameTest() { P4Server pserver = null; P4User target = new P4User(pserver, "Fred"); string expected = "Handy Manny"; string actual; target.FullName = expected; actual = target.FullName; Assert.AreEqual(expected, actual); }
public void UserTest() { P4Server pserver = null; string expected = "Charlie"; P4User target = new P4User(pserver, expected); string actual; // target.User = expected; set in constructor actual = target.User; Assert.AreEqual(expected, actual); }
public void RootTest() { P4Server pserver = null; P4Workspace target = new P4Workspace(pserver, "Fred"); string expected = "Handy Manny"; string actual; target.Root = expected; actual = target.Root; Assert.AreEqual(expected, actual); }
private static void SaveP4Prefs() { settingValues = new string[settings.Length]; envValues = new string[settings.Length]; for (int i = 0; i < settings.Length; i++) { settingValues[i] = P4Server.Get(settings[i]); // also clear the value P4Server.Set(settings[i], ""); } }
public void PasswordTest() { P4Server pserver = null; P4User target = new P4User(pserver, "Fred"); string expected = "Password"; string actual; target.Password = expected; actual = target.Password; Assert.AreEqual(expected, actual); }
public void DescriptionTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", "FredClient"); string expected = "This is a test"; string actual; target.Description = expected; actual = target.Description; Assert.AreEqual(expected, actual); }
public void ParseTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, -1); string spec = ChangeSpec; bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = target.Parse(spec); Assert.AreEqual(expected, actual); Assert.AreEqual(168750, target.ChangeNumber); }
public void JobsTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", "FredClient"); StringList expected = new String[] { "12", "42" }; StringList actual; target.Jobs = expected; actual = target.Jobs; Assert.AreEqual(expected, actual); }
public void FilesTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", "FredClient"); StringList expected = new String[] { "//depot/code/stuff/i.c", "//depot/code/stuff/j.c" }; StringList actual; target.Files = expected; actual = target.Files; Assert.AreEqual(expected, actual); }
public void SubmitOptionsTest() { P4Server pserver = new P4Server(false); P4Workspace target = new P4Workspace(pserver, "Fred"); // possible values: "submitunchanged", "revertunchanged", "leaveunchanged", "submitunchanged+reopen", "revertunchanged+reopen", "leaveunchanged+reopen"; String spec = "submitunchanged"; P4Workspace.SubmitFlags expected = new P4Workspace.SubmitFlags(spec); P4Workspace.SubmitFlags actual; target.SubmitOptions = expected; actual = target.SubmitOptions; String formatted = actual.ToString(); Assert.AreEqual(spec, formatted); spec = "revertunchanged"; expected = new P4Workspace.SubmitFlags(spec); target.SubmitOptions = expected; actual = target.SubmitOptions; formatted = actual.ToString(); Assert.AreEqual(spec, formatted); spec = "leaveunchanged"; expected = new P4Workspace.SubmitFlags(spec); target.SubmitOptions = expected; actual = target.SubmitOptions; formatted = actual.ToString(); Assert.AreEqual(spec, formatted); spec = "submitunchanged+reopen"; expected = new P4Workspace.SubmitFlags(spec); target.SubmitOptions = expected; actual = target.SubmitOptions; formatted = actual.ToString(); Assert.AreEqual(spec, formatted); spec = "revertunchanged+reopen"; expected = new P4Workspace.SubmitFlags(spec); target.SubmitOptions = expected; actual = target.SubmitOptions; formatted = actual.ToString(); Assert.AreEqual(spec, formatted); spec = "leaveunchanged+reopen"; expected = new P4Workspace.SubmitFlags(spec); target.SubmitOptions = expected; actual = target.SubmitOptions; formatted = actual.ToString(); Assert.AreEqual(spec, formatted); }
public void ChangeNumberTest() { P4Server pserver = new P4Server(false); P4Change target = new P4Change(pserver, "fred", "FredClient"); long actual; actual = target.ChangeNumber; Assert.AreEqual(-1, actual); target = new P4Change(pserver, 42); actual = target.ChangeNumber; Assert.AreEqual(42, actual); }
public void RunTest1() { bool unicode = false; string serverAddr = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; // turn off exceptions for this test ErrorSeverity oldExceptionLevel = P4Exception.MinThrowLevel; P4Exception.MinThrowLevel = ErrorSeverity.E_NOEXC; Process p4d = null; for (int i = 0; i < 2; i++) // run once for ascii, once for unicode { try { p4d = Utilities.DeployP4TestServer(TestDir, unicode); using (P4Server server = new P4Server(serverAddr, user, pass, ws_client)) { if (unicode) { Assert.IsTrue(server.UseUnicode, "Unicode server detected as not supporting Unicode"); } else { Assert.IsFalse(server.UseUnicode, "Non Unicode server detected as supporting Unicode"); } P4Command target = new P4Command(server, "help", false, null); P4CommandResult results = target.Run(new String[] { "print" }); Assert.IsTrue(results.Success); P4ClientInfoMessageList helpTxt = target.InfoOutput; Assert.IsNotNull(helpTxt); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } // reset the exception level P4Exception.MinThrowLevel = oldExceptionLevel; }
public void ArgsTest() { bool unicode = false; string serverAddr = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; // turn off exceptions for this test ErrorSeverity oldExceptionLevel = P4Exception.MinThrowLevel; P4Exception.MinThrowLevel = ErrorSeverity.E_NOEXC; Process p4d = null; for (int i = 0; i < 2; i++) // run once for ascii, once for unicode { try { p4d = Utilities.DeployP4TestServer(TestDir, unicode); using (P4Server server = new P4Server(serverAddr, user, pass, ws_client)) { if (unicode) { Assert.IsTrue(server.UseUnicode, "Unicode server detected as not supporting Unicode"); } else { Assert.IsFalse(server.UseUnicode, "Non Unicode server detected as supporting Unicode"); } P4Command target = new P4Command(server); StringList expected = new StringList(new string[] { "a", "b", "c" }); target.Args = expected; StringList actual = target.Args; Assert.AreEqual(expected, actual); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } // reset the exception level P4Exception.MinThrowLevel = oldExceptionLevel; }
public void ParseTest() { P4Server pserver = new P4Server(false); P4Job target = new P4Job(pserver, "new"); bool expected = true; bool actual; actual = target.Parse(spec); Assert.AreEqual(expected, actual); Assert.AreEqual("job042236", target.JobId); Assert.AreEqual("ksawicki", target["OwnedBy"]); // currently, the base parser doesn't save tags without values //Assert.IsTrue(String.IsNullOrEmpty(target["P4Blog"])); }
public void ToStringTest() { P4Server pserver = new P4Server(false); P4Workspace target = new P4Workspace(pserver, "temp"); bool result = target.Parse(spec); Assert.IsTrue(result); Assert.AreEqual(target.Name, "XP1_usr"); String actual = target.ToString(); Assert.IsTrue(actual.StartsWith("Client:\tXP1_usr")); }
public void AltRootsTest() { P4Server pserver = null; P4Workspace target = new P4Workspace(pserver, "Fred"); StringList expected = new StringList(); expected.Add("Pooh Bear"); expected.Add("Smokey Bear"); StringList actual; target.AltRoots = expected; actual = target.AltRoots; Assert.AreEqual(expected, actual); }
public void ViewTest() { P4Server pserver = new P4Server(false); P4Workspace target = new P4Workspace(pserver, "Fred"); WorkspaceView expected = new WorkspaceView(pserver, new String[] { "//depot/a //workspace/a" }); WorkspaceView actual; target.View = expected; actual = target.View; Assert.AreEqual(expected.Count, actual.Count); Assert.AreEqual(expected.GetLeft(0), actual.GetLeft(0)); Assert.AreEqual(expected.GetRight(0), actual.GetRight(0)); Assert.AreEqual(expected.GetType(0), actual.GetType(0)); }
public void ReviewsTest() { P4Server pserver = null; P4User target = new P4User(pserver, "Fred"); StringList expected = new StringList(); expected.Add("//depot/poetry"); expected.Add("//depot/movies"); StringList actual; target.Reviews = expected; actual = target.Reviews; Assert.AreEqual(expected, actual); }
public P4CommandResultWrapper(P4Server server, uint commandId, P4CommandResult p4Result) { m_server = server; m_commandId = commandId; m_p4Result = p4Result; }