示例#1
0
        public void Start_Should_Call_ProcessStarter_With_Correct_Parameters()
        {
            // ARRANGE
            const string location       = @"c:\mongo\bin\mongod.exe";
            var          options        = new MongodExeOptions(27017, @"c:\temp\radom-path");
            var          exeLocatorMock = new Mock <IMongoExeLocator>();

            exeLocatorMock.Setup(l => l.Locate()).Returns(() => location);
            var processStarterMock = new Mock <IProcessStarter>();

            processStarterMock.Setup(starter => starter.Start(It.IsAny <ProcessStartInfo>()))
            .Returns <ProcessStartInfo>(info =>
            {
                var processMock = new Mock <IProcess>();
                processMock.Setup(p => p.StartInfo).Returns(info);

                return(processMock.Object);
            });

            var exeFacade = new MongodExeFacade(exeLocatorMock.Object, processStarterMock.Object);

            // ACT
            IProcess process = exeFacade.Start(options);

            // ASSERT
            processStarterMock.Verify(starter => starter.Start(It.IsAny <ProcessStartInfo>()), Times.Once());
            Assert.Equal(options.ToString(), process.StartInfo.Arguments);
            Assert.Equal(location, process.StartInfo.FileName);
        }
示例#2
0
        public IProcess Start(MongodExeOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string exeLocation      = _exeLocator.Locate();
            string exeArgs          = options.ToString();
            var    processStartInfo = new ProcessStartInfo(exeLocation, exeArgs)
            {
                CreateNoWindow         = true,
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            return(_processStarter.Start(processStartInfo));
        }