public void OnEnded(IExecutorThread thread) { lock (Threads) { Threads.Remove(thread); } }
public void SetUp() { executor = Stub<IExecutor>(); runData = new RunData(); ender = Stub<IThreadEnder>(); target = new ExecutorThreadImpl(executor, runData); }
public void CanLaunch_2ThreadsWithoutGroups_RunDataIsExclusive() { IExecutorThread threadA = Stub <IExecutorThread>(); IExecutorThread threadB = Stub <IExecutorThread>(); threadA.Expect((m) => m.GetRunData()).Return(new RunData() { Groups = new HashSet <string>() }); threadB.Expect((m) => m.GetRunData()).Return(new RunData() { Groups = new HashSet <string>() }); IList <IExecutorThread> threads = new List <IExecutorThread>() { threadA, threadB }; RunData data = new RunData() { Groups = new HashSet <string>() { "Group1" }, Exclusive = true }; bool actual = VerifyTarget(() => target.CanLaunch(threads, data)); Assert.IsTrue(actual); }
public void CanLaunch_2ThreadsWithTheGroup() { IExecutorThread threadA = Stub <IExecutorThread>(); IExecutorThread threadB = Stub <IExecutorThread>(); threadA.Expect((m) => m.GetRunData()).Return(new RunData() { Groups = new HashSet <string>() { "Group2" } }); threadB.Expect((m) => m.GetRunData()).Return(new RunData() { Groups = new HashSet <string>() { "Group1" } }); IList <IExecutorThread> threads = new List <IExecutorThread>() { threadA, threadB }; RunData data = new RunData() { Groups = new HashSet <string>() { "Group1" } }; bool actual = VerifyTarget(() => target.CanLaunch(threads, data)); Assert.IsFalse(actual); }
public void SetUp() { executor = Stub <IExecutor>(); runData = new RunData(); ender = Stub <IThreadEnder>(); target = new ExecutorThreadImpl(executor, runData); }
public void Create() { IExecutor executor = Stub <IExecutor>(); IThreadStarter starter = Stub <IThreadStarter>(); RunData data = new RunData(); starter.Expect((m) => m.OnStarted(Arg <IExecutorThread> .Is.NotNull)); IExecutorThread thread = VerifyTarget(() => target.Create(executor, data, starter)); Assert.AreEqual(data, thread.GetRunData()); Assert.AreEqual(executor, thread.GetExecutor()); Assert.IsNull(thread.GetTask()); }
public void SetUp() { target = new ExecutorLauncherImpl(); threadFactory = Stub <IThreadFactory>(); args = Stub <ITestRunnerArgs>(); executor = Stub <IExecutor>(); threads = Stub <IList <IExecutorThread> >(); thread = Stub <IExecutorThread>(); target.ThreadFactory = threadFactory; target.Args = args; target.Executor = executor; target.Threads = threads; }
public bool LaunchExecutor(RunData runData) { IExecutorThread thread = null; lock (Threads) { if (!ThreadFactory.CanLaunch(Threads, runData)) { return(false); } thread = ThreadFactory.Create(Executor, runData, this); } thread.Launch(this); return(true); }
public void GetTaskArray() { IExecutorThread a = Stub <IExecutorThread>(); IExecutorThread b = Stub <IExecutorThread>(); IExecutorThread c = Stub <IExecutorThread>(); IList <IExecutorThread> input = new List <IExecutorThread>() { a, b, c }; Task taskA = new Task(() => Console.WriteLine("TASK_A")); Task taskB = new Task(() => Console.WriteLine("TASK_B")); Task taskC = new Task(() => Console.WriteLine("TASK_C")); a.Expect((m) => m.GetTask()).Return(taskA); b.Expect((m) => m.GetTask()).Return(taskB); c.Expect((m) => m.GetTask()).Return(taskC); Task[] tasks = VerifyTarget(() => target.GetTaskArray(input)); Assert.AreEqual(taskA, tasks[0]); Assert.AreEqual(taskB, tasks[1]); Assert.AreEqual(taskC, tasks[2]); }
public void OnStarted(IExecutorThread thread) { Threads.Add(thread); }
public void SetUp() { target = new ExecutorLauncherImpl(); threadFactory = Stub<IThreadFactory>(); args = Stub<ITestRunnerArgs>(); executor = Stub<IExecutor>(); threads = Stub<IList<IExecutorThread>>(); thread = Stub<IExecutorThread>(); target.ThreadFactory = threadFactory; target.Args = args; target.Executor = executor; target.Threads = threads; }