|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;
using System.Diagnostics;
using LoopExecution;
namespace LoopExecutionTest
{
[TestClass]
public class LoopExecutionTest
{
[TestMethod]
public void Assert_That_Loops_Run()
{
List<int> listOfInt = new List<int>();
int numberOfTimesToRun = 32;
for (int i = 0; i < numberOfTimesToRun; i++)
{
listOfInt.Add(i);
}
LoopExecution<int> loopExecution = new LoopExecution<int>();
loopExecution.ExecutionMethod += new LoopExecution<int>.MethodToExecute(loopExecution_ExecutionMethod);
loopExecution.CollectionToIterateOver = listOfInt;
loopExecution.Execute();
Assert.IsTrue(loopExecution.NormalLoopTime > 0);
Assert.IsTrue(loopExecution.ThreadLoopTime > 0);
Assert.IsTrue(loopExecution.ThreadPoolLoopTime > 0);
Assert.IsTrue(loopExecution.TaskLoopTime > 0);
}
void loopExecution_ExecutionMethod(object sender, LoopExecution<int>.LoopExecutionEventArgs e)
{
Debug.WriteLine("{0} number {1}. Thread name : {2}. Object operating on {3}", e.MethodName, e.LoopExecutionNumber, Thread.CurrentThread.ManagedThreadId, e.ObjectToOperateOn);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Engineer who started coding when I was 5. Core focus is to meet clients real business needs through initial consultation, followed by a communicative and collaborative approach. Delivers applications using C# .net and MS SQL Server. Comfortable working independently, in a team, or mentoring to meets deadlines irrelevant of pressure.
Currently interested in cloud computing with a focus on Microsoft Azure