コード例 #1
0
ファイル: Repository.cs プロジェクト: uon-coehm/IQMobile
 public void Dispose()
 {
     if (Context != null)
     {
         Context.Dispose();
     }
 }
コード例 #2
0
ファイル: UnitOfWork.cs プロジェクト: uon-coehm/IQMobile
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         _context?.Dispose();
     }
 }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
ファイル: ProgramSet.cs プロジェクト: Landrash/ZoneLighting
 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;
 }
コード例 #5
0
        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());
            }
        }
コード例 #6
0
        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());
            }
        }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
ファイル: UnitOfWork.cs プロジェクト: uon-coehm/IQMobile
 public virtual void CommitSqlCommand()
 {
     _context.SaveChanges();
     _context.Dispose();
     _context = new SyncContext();
 }