/// <summary> /// Tests that merging dictionaries from different threads works properly. /// </summary> public void TestMultithreadedMergeWorksProperly() { var dataAggregator = new DataAggregator(); Thread[] threads = new Thread[ThreadsCount]; for (int i = 0; i < threads.Length; i++) { int threadNumber = i; threads[i] = new Thread(() => { for (int j = 0; j < MergeOperationsCount; j++) { dataAggregator.MergeData(multiThreadedDictionaries[threadNumber]); } }); } foreach (Thread thread in threads) { thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } IDictionary <string, long> actualData = dataAggregator.GetData(); TestHelpers.AssertEqualsDictionaries(expectedMultiThreadedResult, actualData); }
public void TestDictionariesAreProperlyMerged() { var dataAggregator = new DataAggregator(); dataAggregator.MergeData(firstDictionary); dataAggregator.MergeData(secondDictionary); IDictionary <string, long> actualData = dataAggregator.GetData(); TestHelpers.AssertEqualsDictionaries(expectedData, actualData); }
public void RunComboAggregatorTest() { PropertyInfo prop = typeof(IncidentData).GetProperty("Time"); MonthOfYearAggregator <IncidentData> moyAggTest = new MonthOfYearAggregator <IncidentData>(); moyAggTest.Member = prop; CategoryAggregator <IncidentData> locAggTest = new CategoryAggregator <IncidentData>(); locAggTest.Member = typeof(IncidentData).GetProperty("Location"); // CategoryAggregator<IncidentData> codeAggTest = new CategoryAggregator<IncidentData>(); // codeAggTest.Member = typeof(IncidentData).GetProperty("Code"); List <DataAggregator <IncidentData> > aggregators = new List <DataAggregator <IncidentData> >(); aggregators.Add(locAggTest); aggregators.Add(moyAggTest); // aggregators.Add(codeAggTest); Dictionary <object, object> dictionary = DataAggregator <IncidentData> .GetData(aggregators, Incidents); Console.WriteLine(JsonConvert.SerializeObject(dictionary)); }