public static void Sync_ThreeStepperSyncingWithOne_Consecutive_Works(int numberOfChecks) { DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "START"); //create a sync context to conduct the test with var testContext = new SyncContext(); //create two programs to be synced var stepperA = new StepperInternalLoop("A"); var stepperB = new StepperInternalLoop("B"); var stepperC = new StepperInternalLoop("C"); var stepperD = new StepperInternalLoop("D"); IStepper[] steppers = { stepperA, stepperB, stepperC, stepperD }; //sync and start A DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Sync-Starting Stepper A"); testContext.Sync(stepperA); testContext.SyncFinished.WaitForFire(); //start BCD in sync with testContext when steppers A is back to the beginning DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Syncing Stepper B"); testContext.Sync(stepperB); testContext.SyncFinished.WaitForFire(); DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Syncing Stepper C"); testContext.Sync(stepperC); testContext.SyncFinished.WaitForFire(); DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Syncing Stepper D"); testContext.Sync(stepperD); testContext.SyncFinished.WaitForFire(); int[,] stepperSteps; DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Validating Sync Phases"); var invalidStepIndex = ValidateStepperSyncPhase(steppers, out stepperSteps, numberOfChecks); var result = invalidStepIndex.Length == 0; //cleanup DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Disposing Stepper A"); stepperA.Dispose(true); DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Disposing Stepper B"); stepperB.Dispose(true); DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Disposing Stepper C"); stepperC.Dispose(true); DebugTools.AddEvent("Sync_ThreeStepperSyncingWithOne_Works", "Disposing Stepper D"); stepperD.Dispose(true); testContext.Dispose(); //assert if (result) { Assert.Pass(); } else { var failStringBuilder = BuildFailString(invalidStepIndex, steppers, stepperSteps); Assert.Fail(failStringBuilder.ToString()); } }
public static void Sync_OneStepper_Works(int numberOfChecks) { DebugTools.AddEvent("Sync_OneStepperSyncingWithThree_Works", "START"); //create a sync context to conduct the test with var testContext = new SyncContext(); //create two programs to be synced var stepperA = new StepperInternalLoop("A"); IStepper[] steppers = { stepperA }; //sync and start ABC DebugTools.AddEvent("Sync_OneStepperSyncingWithThree_Works", "Sync-Starting Stepper A, B, C"); testContext.Sync(stepperA); testContext.SyncFinished.WaitForFire(); int[,] stepperSteps; var invalidStepIndex = ValidateStepperSyncPhase(steppers, out stepperSteps, numberOfChecks); var result = invalidStepIndex.Length == 0 && stepperSteps.Length != 0; //cleanup DebugTools.AddEvent("Sync_OneStepperSyncingWithThree_Works", "Disposing Stepper A"); stepperA.Dispose(true); testContext.Dispose(); if (result) { Assert.Pass(); } else { var failStringBuilder = BuildFailString(invalidStepIndex, steppers, stepperSteps); Assert.Fail(failStringBuilder.ToString()); } }