Exemplo n.º 1
0
        public void AbortTimer_ShouldDisableTimerActive()
        {
            Mock <ITimedScopeLogger>        timedScopeLoggerMock       = new Mock <ITimedScopeLogger>();
            Mock <IReplayEventConfigurator> replyEventConfiguratorMock = new Mock <IReplayEventConfigurator>();
            Mock <ICallContextManager>      callContextManagerMock     = new Mock <ICallContextManager>();

            IMachineInformation     machineInformation     = new UnitTestMachineInformation();
            ITimedScopeStackManager timedScopeStackManager = new TimedScopeStackManager(callContextManagerMock.Object, machineInformation);

            using (TimedScope scope = TestHooks.CreateDefaultTimedScope(timedScopeLoggerMock.Object, replyEventConfiguratorMock.Object, machineInformation: machineInformation,
                                                                        timedScopeStackManager: timedScopeStackManager))
            {
                Assert.True(scope.IsScopeActive, "Default scope should have timer active.");

                scope.AbortTimer();
                Assert.False(scope.IsScopeActive, "Aborting timer should stop timer.");
            }
        }
Exemplo n.º 2
0
        public void AbortTimer_ShouldDisableTimerActive_AndSetResultsToFalse()
        {
            Mock <ITimedScopeLogger>        timedScopeLoggerMock       = new Mock <ITimedScopeLogger>();
            Mock <IReplayEventConfigurator> replyEventConfiguratorMock = new Mock <IReplayEventConfigurator>();
            Mock <ICallContextManager>      callContextManagerMock     = new Mock <ICallContextManager>();

            IMachineInformation     machineInformation     = new UnitTestMachineInformation();
            ITimedScopeStackManager timedScopeStackManager = new TimedScopeStackManager(callContextManagerMock.Object, machineInformation);

            using (TimedScope scope = TestHooks.CreateDefaultTimedScope(scopeLogger: timedScopeLoggerMock.Object, replayEventConfigurator: replyEventConfiguratorMock.Object,
                                                                        machineInformation: machineInformation, timedScopeStackManager: timedScopeStackManager, startScope: false))
            {
                Assert.False(scope.IsScopeActive, "Default scope started without an active scope should have timer active.");

                scope.Start();

                Assert.True(scope.IsScopeActive, "Default scope should have timer active.");

                scope.AbortTimer(false);
                Assert.False(scope.IsScopeActive, "Aborting timer should stop timer.");
                Assert.True(scope.IsSuccessful.HasValue, "IsSuccessful should be set.");
                Assert.False(scope.IsSuccessful.Value, "IsSuccesful should be set to false.");
            }
        }