コード例 #1
0
        public void StartProcessDumpForHangWillStartProcDumpExeWithCorrectParams()
        {
            var guid                 = "guid";
            var process              = "process";
            var processId            = 12345;
            var filename             = $"{process}_{processId}_{guid}_hangdump.dmp";
            var args                 = $"-accepteula -n 1 -ma {processId} {filename}";
            var testResultsDirectory = "D:\\TestResults";

            this.mockProcessHelper.Setup(x => x.LaunchProcess(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null, null, null, It.IsAny <Action <object, string> >()))
            .Returns(this.mockProcDumpProcess.Object);
            this.mockProcessHelper.Setup(x => x.GetProcessName(processId))
            .Returns(process);
            this.mockFileHelper.Setup(x => x.GetFiles(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <SearchOption>()))
            .Returns(new string[] { Path.Combine(testResultsDirectory, filename) });

            var processDumpUtility = new ProcessDumpUtility(
                this.mockProcessHelper.Object,
                this.mockFileHelper.Object,
                this.mockPlatformEnvironment.Object,
                this.mockNativeMethodsHelper.Object);

            processDumpUtility.StartHangBasedProcessDump(processId, guid, testResultsDirectory, isFullDump: true);

            this.mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny <string>(), args, It.IsAny <string>(), null, null, null, It.IsAny <Action <object, string> >()), Times.Once);
            Assert.AreEqual(Path.Combine(testResultsDirectory, filename), processDumpUtility.GetDumpFile());
        }