public StopProcessHandlerTests()
        {
            var process1 = Substitute.For <IProcess>();

            process1.Id.Returns(1);

            var process2 = Substitute.For <IProcess>();

            process2.Id.Returns(2);

            Processes = new[]
            {
                process1,
                process2,
            };

            Process1Key = Guid.NewGuid();
            Process2Key = Guid.NewGuid();
            Process3Key = Guid.NewGuid();

            ProcessTracker = Substitute.For <IProcessTracker>();
            ProcessTracker.GetProcessByKey(Process1Key).Returns(process1);
            ProcessTracker.GetProcessByKey(Process2Key).Returns(process2);
            ProcessTracker.GetProcessByKey(Process3Key).Returns(x => null);

            Handler = new StopProcessHandler(ProcessTracker);
        }
        public async void WhenProcessIsNotTracked_Throws()
        {
            ExpectedParams.key = Guid.NewGuid();
            ProcessTracker.GetProcessByKey(ExpectedParams.key).Returns((IProcess)null);

            var ex = await Record.ExceptionAsync(async() => await Handler.ExecuteAsync(ExpectedParams));

            Assert.Equal(
                String.Format("A process with key '{0}' is not being tracked.", ExpectedParams.key),
                ex.Message);
        }
Пример #3
0
            public void AddsProcessToTracker()
            {
                var processKey = Guid.NewGuid();
                var process    = Substitute.For <IProcess>();

                ProcessTracker.TrackProcess(processKey, process);

                var result = ProcessTracker.GetProcessByKey(processKey);

                Assert.Same(process, result);
            }
Пример #4
0
            public void RemovesProcessFromList()
            {
                var processKey = Guid.NewGuid();
                var process    = Substitute.For <IProcess>();

                ProcessTracker.TrackProcess(processKey, process);
                Assert.NotNull(ProcessTracker.GetProcessByKey(processKey));

                var result = ProcessTracker.RemoveProcess(processKey);

                Assert.True(result);
                Assert.Null(ProcessTracker.GetProcessByKey(processKey));
            }
        public WaitForProcessExitHandlerTests()
        {
            ProcessTracker = Substitute.For <IProcessTracker>();

            Handler = new WaitForProcessExitHandler(ProcessTracker);

            ExpectedParams = new WaitForProcessExitParams
            {
                key     = Guid.NewGuid(),
                timeout = 100,
            };

            ExpectedProcess = Substitute.For <IProcess>();

            ProcessTracker.GetProcessByKey(ExpectedParams.key).Returns(ExpectedProcess);
        }
Пример #6
0
            public void WhenProcessIsNotTracked_ReturnsNull()
            {
                var process = ProcessTracker.GetProcessByKey(Guid.NewGuid());

                Assert.Null(process);
            }
Пример #7
0
            public void WhenProcessIsTracked_ReturnsProcess()
            {
                var process = ProcessTracker.GetProcessByKey(KnownProcessKey);

                Assert.Same(KnownProcess, process);
            }