public void DoActionOnConcurrentObjectsShouldCallAllObjects() { var createdSampleClasses = new List <SampleConcurrentClass>(); Func <SampleConcurrentClass> sampleCreator = () => { var sample = new SampleConcurrentClass(); createdSampleClasses.Add(sample); return(sample); }; this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 4, true); Assert.AreEqual(4, createdSampleClasses.Count, "Number of Concurrent Objects created should be 4"); int count = 0; this.proxyParallelManager.DoActionOnAllConcurrentObjects( (sample) => { count++; Assert.IsTrue(createdSampleClasses.Contains(sample), "Called object must be in the created list."); // Make sure action is not called on same object multiple times createdSampleClasses.Remove(sample); }); Assert.AreEqual(4, count, "Number of Concurrent Objects called should be 4"); Assert.AreEqual(0, createdSampleClasses.Count, "All concurrent objects must be called."); }
public void InitializeTests() { Func <SampleConcurrentClass> sampleCreator = () => { return(new SampleConcurrentClass()); }; this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 2, true); }
public void AbstractProxyParallelManagerShouldCreateCorrectNumberOfConcurrentObjects() { var createdSampleClasses = new List <SampleConcurrentClass>(); Func <SampleConcurrentClass> sampleCreator = () => { var sample = new SampleConcurrentClass(); createdSampleClasses.Add(sample); return(sample); }; this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 3, true); Assert.AreEqual(3, createdSampleClasses.Count, "Number of Concurrent Objects created should be 3"); }