/// <summary> /// Construct a P4ChangelistSpanQuery from the dates specified as parameters; the dates are not required to be in order /// </summary> /// <param name="InQueryDateTimeStart">The start or end date for the query</param> /// <param name="InQueryDateTimeEnd">The start or end date for the query, whichever wasn't specified by the first parameter</param> /// <param name="InDepotFilter">Path to filter the depot by</param> /// <param name="InUserFilter">User to filter the depot by, can be empty string</param> public P4ChangelistSpanQuery(DateTime InQueryDateTimeStart, DateTime InQueryDateTimeEnd, String InDepotFilter, String InUserFilter = "") : base(InDepotFilter, InUserFilter) { // Reorder the changelists increasing ReOrder(ref InQueryDateTimeStart, ref InQueryDateTimeEnd); DateTimeVersion StartDateTime = new DateTimeVersion(InQueryDateTimeStart); DateTimeVersion EndDateTime = new DateTimeVersion(InQueryDateTimeEnd); VersionRange Versions = new VersionRange(StartDateTime, EndDateTime); mFileFilter = new FileSpec(new DepotPath(InDepotFilter), null, null, Versions); }
/// <summary> /// Construct a P4ChangelistSpanQuery from the dates specified as parameters; the dates are not required to be in order /// </summary> /// <param name="InQueryDateTimeStart">The start or end date for the query</param> /// <param name="InQueryDateTimeEnd">The start or end date for the query, whichever wasn't specified by the first parameter</param> /// <param name="InDepotFilter">Path to filter the depot by</param> /// <param name="InUserFilter">User to filter the depot by, can be empty string</param> public P4ChangelistSpanQuery(DateTime InQueryDateTimeStart, DateTime InQueryDateTimeEnd, String InDepotFilter, String InUserFilter = "") : base(InDepotFilter, InUserFilter) { // Reorder the changelists increasing ReOrder(ref InQueryDateTimeStart, ref InQueryDateTimeEnd); DateTimeVersion StartDateTime = new DateTimeVersion(InQueryDateTimeStart); DateTimeVersion EndDateTime = new DateTimeVersion(InQueryDateTimeEnd); VersionRange Versions = new VersionRange(StartDateTime, EndDateTime); mFileFilter = new FileSpec(new DepotPath(InDepotFilter), null, null, Versions); }
public void DateTimeTest() { DateTime dateTime = DateTime.Now; ClientPath cp = new ClientPath("c:\foobarclient"); VersionSpec vs = new DateTimeVersion(dateTime); FileSpec target = new FileSpec(cp, vs); string dateTimeString = vs.ToString(); string expected = String.Format("@{0}", dateTime.ToString("yyyy/MM/dd:HH:mm:ss")); Assert.AreEqual(expected, dateTimeString); dateTime = DateTime.Now; cp = new ClientPath("c:\foobarclient"); vs = new DateTimeVersion(dateTime); target = new FileSpec(cp, vs); dateTimeString = vs.ToString(); expected = cp.ToString() + "@" + dateTime.ToString("yyyy/MM/dd:HH:mm:ss"); Assert.AreEqual(expected, FileSpec.ToStrings(target)[0]); }
public void VersionSpecTest1() { VersionSpec left = new VersionRange(1, 2); VersionSpec rightpos = new VersionRange(1, 2); VersionSpec rightneg1 = new VersionRange(1, 4); VersionSpec rightneg2 = new Revision(1); VersionSpec rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new HeadRevision(); rightpos = new HeadRevision(); rightneg1 = new HaveRevision(); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightnull)); left = new HaveRevision(); rightpos = new HaveRevision(); rightneg1 = new HeadRevision(); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightnull)); left = new NoneRevision(); rightpos = new NoneRevision(); rightneg1 = new HaveRevision(); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightnull)); left = new Revision(1); rightpos = new Revision(1); rightneg1 = new Revision(3); rightneg2 = new VersionRange(1, 4); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new DateTimeVersion(DateTime.MinValue); rightpos = new DateTimeVersion(DateTime.MinValue); rightneg1 = new DateTimeVersion(DateTime.MaxValue); rightneg2 = new Revision(3); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new LabelNameVersion("label_name"); rightpos = new LabelNameVersion("label_name"); rightneg1 = new LabelNameVersion("wrong_label_name"); rightneg2 = new Revision(3); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new ChangelistIdVersion(44444); rightpos = new ChangelistIdVersion(44444); rightneg1 = new ChangelistIdVersion(88888); rightneg2 = new Revision(3); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new ClientNameVersion("client_name"); rightpos = new ClientNameVersion("client_name"); rightneg1 = new ClientNameVersion("wrong_client_name"); rightneg2 = new Revision(3); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new ActionVersion("#add"); rightpos = new ActionVersion("#add"); rightneg1 = new ActionVersion("#branch"); rightneg2 = new Revision(3); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); }
///A test for GetChangelistsjob097882 ///</summary> public void GetChangelistsTestjob097882(bool unicode) { string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; Process p4d = Utilities.DeployP4TestServer(TestDir, 13, unicode); Server server = new Server(new ServerAddress(uri)); try { Repository rep = new Repository(server); using (Connection con = rep.Connection) { con.UserName = user; con.Client = new Client(); con.Client.Name = ws_client; bool connected = con.Connect(null); Assert.IsTrue(connected); Assert.AreEqual(con.Status, ConnectionStatus.Connected); ChangesCmdOptions opts = new ChangesCmdOptions(ChangesCmdFlags.None, null, 0, ChangeListStatus.Submitted, null); FileSpec fs = new FileSpec(); fs.DepotPath = new DepotPath("//depot/..."); //// Creates and initializes a CultureInfo. This is to create //// a date with - as the seperator CultureInfo myCI = new CultureInfo("en-US", false); //// Clones myCI and modifies the DTFI and NFI instances associated with the clone. CultureInfo myCIclone = (CultureInfo)myCI.Clone(); myCIclone.DateTimeFormat.DateSeparator = "-"; System.Threading.Thread.CurrentThread.CurrentCulture = myCIclone; DateTime dts = new DateTime(2011, 5, 23, 1, 19, 17); DateTime dte = new DateTime(2011, 5, 25, 1, 19, 17); // confirm that the dates have dashes as seperators Assert.IsTrue(dts.ToString().Contains("5-23-2011")); Assert.IsTrue(dte.ToString().Contains("5-25-2011")); DateTimeVersion start = new DateTimeVersion(dts); DateTimeVersion end = new DateTimeVersion(dte); fs.Version = new VersionRange(start, end); IList <Changelist> changes = rep.GetChangelists(opts, fs); Assert.AreEqual(changes.Count, 4); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } }