public static void AddTaskSequence(this IUnitTestRun run, RemoteTaskPacket sequence, SilverlightUnitTestElement silverlightElement, IUnitTestRun originalRun) { var runTasks = run.GetField<Dictionary<IUnitTestElement, RemoteTask>>("myElementsToTasks"); var runTaskIdsToElements = run.GetField<Dictionary<string, IUnitTestElement>>("myTaskIdsToElements"); var runElementsToTasks = run.GetField<Dictionary<IUnitTestElement, RemoteTask>>("myElementsToTasks"); if (runTasks == null) { runTasks = new Dictionary<IUnitTestElement, RemoteTask>(); run.SetField("myElementsToTasks", runTasks); } if (runTaskIdsToElements == null) { runTaskIdsToElements = new Dictionary<string, IUnitTestElement>(); run.SetField("myTaskIdsToElements", runTaskIdsToElements); } if (runElementsToTasks == null) { runElementsToTasks = new Dictionary<IUnitTestElement, RemoteTask>(); run.SetField("myElementsToTasks", runElementsToTasks); } foreach (var unitTestTask in sequence.GetAllTasksRecursive()) { var element = originalRun.GetElementByRemoteTaskId(unitTestTask.Task.Id); if (element != null) { runTasks[element] = unitTestTask.Task; runTaskIdsToElements[unitTestTask.Task.Id] = element; runElementsToTasks[element] = unitTestTask.Task; } } run.GetRootTasks().Add(sequence); runTasks[silverlightElement] = sequence.Task; runTaskIdsToElements[sequence.Task.Id] = silverlightElement; runElementsToTasks[silverlightElement] = sequence.Task; }
private static void ConvertToSilverlightSequenceIfNecessary(RemoteTaskPacket sequence, ref IUnitTestRun run, IUnitTestLaunch launch, IUnitTestProvider provider, ITaskRunnerHostController hostController) { if (!sequence.IsSilverlightSequence()) { var silverlightProject = sequence.GetSilverlightProject(run); if (silverlightProject != null) { var silverlightRun = launch.GetOrCreateSilverlightRun(silverlightProject.PlatformID, provider, hostController); var silverlightElement = new SilverlightUnitTestElement(new UnitTestElementId(provider, run.Elements.First().Id.PersistentProjectId, Guid.NewGuid().ToString()), silverlightRun.Key.RunStrategy); var remoteTask = new SilverlightUnitTestTask(silverlightProject.PlatformID.Version, silverlightProject.GetXapPath(), silverlightProject.GetDllPath()); var silverlightSequence = new RemoteTaskPacket(remoteTask) { TaskPackets = { sequence } }; run.GetRootTasks().Remove(sequence); silverlightRun.Value.AddTaskSequence(silverlightSequence, silverlightElement, run); run = silverlightRun.Value; } } }