public void TearDown() { jsc = null; ta2 = null; ta1 = null; ta3 = null; }
public void SetUp() { jsc = new JobSortedCollection(new DefaultPrioritizer()); ta1 = new MockTradeActivityItem("AS", DateTime.Today, 1, 2, 3, JobStatus.Queued); ta2 = new MockTradeActivityItem("AS", DateTime.Today.AddDays(-2), 1, 2, 3, JobStatus.Queued); ta3 = new MockTradeActivityItem("AS", DateTime.Today.AddDays(-1), 1, 2, 3, JobStatus.Queued); }
/// <summary> /// <para>Gets list of jobs with given service ID. Returns empty collection if manager doesn't contain job with /// given status </para> /// </summary> /// <param name="serviceID">job service ID</param> /// <returns>collection of jobs with given service ID</returns> public ReadOnlyCollection <ITradeActivityItem> GetJobsByServiceID(long serviceID) { JobSortedCollection jobs; lock (syncRoot) { //Create a new JobSortedCollection if none was found if (!jobsByServiceId.TryGetValue(serviceID, out jobs)) { jobs = new JobSortedCollection(new DefaultPrioritizer()); jobsByServiceId[serviceID] = jobs; } return(jobs); } }
/// <summary> /// <para>Gets list of jobs with given status and service ID. /// Returns empty collection if manager doesn't contain job with given status and service ID </para> /// </summary> /// <exception cref="ArgumentException">if status is not valid <see cref="JobStatus"/> value</exception> /// <param name="status">job status</param> /// <param name="serviceID">job service ID</param> /// <returns>collection of job with given parameters</returns> public ReadOnlyCollection <ITradeActivityItem> GetJobsByStatusAndServiceID(JobStatus status, long serviceID) { JobInfo jobInfo = new JobInfo(serviceID, status); JobSortedCollection jobs; lock (syncRoot) { jobsByStatusAndServiceID.TryGetValue(jobInfo, out jobs); //Create a new JobSortedCollection if none was found if (jobs == null) { jobs = new JobSortedCollection(new DefaultPrioritizer()); jobsByStatusAndServiceID[jobInfo] = jobs; } return(jobs); } }
/// <summary> /// <para>Gets list of jobs with given status. /// Returns empty collection if manager doesn't contain job with given status.</para> /// </summary> /// <exception cref="ArgumentException">if status is not valid <see cref="JobStatus"/> value</exception> /// <param name="status">job status</param> /// <returns>collection of jobs with given status</returns> public ReadOnlyCollection <ITradeActivityItem> GetJobsByStatus(JobStatus status) { Helper.ValidateJobStatus(status, "status"); JobSortedCollection jobs; lock (syncRoot) { jobsByStatus.TryGetValue((int)status, out jobs); //Create a new JobSortedCollection if none was found if (jobs == null) { jobs = new JobSortedCollection(new DefaultPrioritizer()); jobsByStatus[(int)status] = jobs; } return(jobs); } }
/// <summary> /// Adds an <see cref="ITradeActivityItem"/> instance (job) to the given dictionary. /// If the key to be found is not found in the dictionary, /// then a new entry (<see cref="JobSortedCollection"/> instance) is added to the dictionary and the job is /// added to the new <see cref="JobSortedCollection"/> instance. /// </summary> /// <typeparam name="T">The type of key of the dictionary.</typeparam> /// <param name="index">The dictionary in which to add.</param> /// <param name="keyToFind">The key which is supposed to be found in the dictionary.</param> /// <param name="jobToAdd">The job that needs to be added to the dictionary.</param> private static void AddTradeActivityItemToIndex <T>(IDictionary <T, JobSortedCollection> index, T keyToFind, ITradeActivityItem jobToAdd) { //Check if the key is already present in the index JobSortedCollection coll; index.TryGetValue(keyToFind, out coll); if (coll == null) { //Create new JobSortedCollection coll = new JobSortedCollection(new DefaultPrioritizer()); //Add the new JobSortedCollection to the dictionary index[keyToFind] = coll; } //Add the job to the created or found JobSortedCollection coll.Add(jobToAdd); }