Пример #1
0
 public void CompletedEventTest()
 {
     var param0 = new PrivateObject(new MockProcess());
     var target = new Process_Accessor(param0);
     Assert.IsNotNull(target.CompletedEvent);
 }
Пример #2
0
 public void SetExecutionStateTest()
 {
     var param0 = new PrivateObject(CreateProcess());
     var target = new Process_Accessor(param0);
     ProcessExecutionState state = ProcessExecutionState.Finished;
     target.SetExecutionState(state);
     Assert.AreEqual<ProcessExecutionState>(target.ExecutionState, state);
     // changing in case the initial value was equal to the previous state.
     state = ProcessExecutionState.Stopped;
     target.SetExecutionState(state);
     Assert.AreEqual<ProcessExecutionState>(target.ExecutionState, state);
 }
Пример #3
0
        public void StopTest()
        {
            var param0 = new PrivateObject(new MockProcess());
            var process = new Process_Accessor(param0);

            //var resetEvent = MockRepository.GenerateStub<EventWaitHandle>(false, EventResetMode.ManualReset);

            //process.completedEvent = resetEvent;
            //resetEvent.Stub(r => r.Set());

            bool stoppingEventCalled = false;
            bool stoppedEventCalled = false;

            process.add_Stopping((s, a) =>
                                    {
                                        stoppingEventCalled = true;
                                        Assert.AreEqual<ProcessExecutionState>(ProcessExecutionState.StopRequested, process.ExecutionState);
                                    });
            process.add_Stopped((s, a) =>
                                    {
                                        stoppedEventCalled = true;
                                        Assert.AreEqual<ProcessExecutionState>(ProcessExecutionState.Stopped,
                                                                               process.ExecutionState);
                                    });

            process.Stop();

            //resetEvent.AssertWasCalled(r => r.Set());

            Assert.IsTrue(stoppingEventCalled);
            Assert.IsTrue(stoppedEventCalled);

            Assert.AreEqual<ProcessExecutionState>(ProcessExecutionState.Stopped, process.ExecutionState);
        }
Пример #4
0
        public void OnTerminatedTest()
        {
            PrivateObject param0 = new PrivateObject(CreateProcess());
            Process_Accessor target = new Process_Accessor(param0);
            ProcessExitEventArgs eventArgs = new ProcessExitEventArgs {CompletionState = new {Field = 123}};

            bool terminatedEventCalled = false;

            target.add_Terminated((s, e)=>
                                      {
                                          terminatedEventCalled = true;
                                          Assert.AreEqual<ProcessExecutionState>(ProcessExecutionState.Terminated, target.ExecutionState);
                                      });

            target.OnTerminated(eventArgs);

            Assert.IsTrue(terminatedEventCalled);
        }