public void Dispose() { if (Context != null) { Context.Dispose(); } }
private void Dispose(bool disposing) { if (disposing) { _context?.Dispose(); } }
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 void Dispose(bool force) { Name = null; if (Zones != null) { ZonePrograms.Parallelize(zp => zp?.Stop(force)); } ZonePrograms?.ForEach(zoneProgram => zoneProgram?.Dispose()); Zones?.ForEach(zone => zone?.UnsetProgram()); Zones = null; ProgramName = null; SyncContext?.Dispose(); SyncContext = null; }
public static void Sync_FourSteppers_Simultaneous_Works(int numberOfChecks) { DebugTools.AddEvent("Sync_FourSteppers_Works", "START"); //create a sync context to conduct the test with var testContext = new SyncContext(); //create two programs to be synced var stepperA = new Stepper("A"); var stepperB = new Stepper("B"); var stepperC = new Stepper("C"); var stepperD = new Stepper("D"); IStepper[] steppers = { stepperA, stepperB, stepperC, stepperD }; //sync and start testContext.Sync(stepperA, stepperB, stepperC, stepperD); testContext.SyncFinished.WaitForFire(); int[,] stepperSteps; var invalidStepIndex = ValidateStepperSyncPhase(steppers, out stepperSteps, numberOfChecks); var result = invalidStepIndex.Length == 0; PrintStepperSteps(steppers, stepperSteps); //cleanup stepperA.Dispose(true); stepperB.Dispose(true); stepperC.Dispose(true); stepperD.Dispose(true); testContext.Dispose(); //assert if (result) { Assert.Pass(); } else { var failStringBuilder = BuildFailString(invalidStepIndex, steppers, stepperSteps); Assert.Fail(failStringBuilder.ToString()); } }
public void Unsync_TwoSteppers_Works(int numberOfChecks, int maxOutOfSyncDueToThreadTestBlip) { //create a sync context to conduct the test with var testContext = new SyncContext(); //create two programs to be synced var stepperA = new Stepper("A"); var stepperB = new Stepper("B"); IStepper[] steppers = { stepperA, stepperB }; //sync and start testContext.Sync(stepperA, stepperB); testContext.SyncFinished.WaitForFire(); //act testContext.Unsync(stepperB); //gather data int[,] stepperSteps; var invalidStepIndex = ValidateStepperSyncPhase(steppers, out stepperSteps, numberOfChecks); var result = invalidStepIndex.Length > maxOutOfSyncDueToThreadTestBlip; PrintStepperSteps(steppers, stepperSteps); //cleanup stepperA.Dispose(true); stepperB.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()); } }
public virtual void CommitSqlCommand() { _context.SaveChanges(); _context.Dispose(); _context = new SyncContext(); }