Exemplo n.º 1
0
        public void FormatCurrentProcessId_on_execute_should_return_expected()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var expected = 3500;
                PULDllImport.GetCurrentProcessId().Body = () => expected;

                // Act
                var actual = new ULDllImport().FormatCurrentProcessId();

                // Assert
                Assert.AreEqual(string.Format("The current process ID is {0}", expected), actual);
            }
        }
Exemplo n.º 2
0
        public void Is64BitProcessMessage_on_64_bit_execute_should_return_expected()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PULDllImport.IsWow64ProcessIntPtrBooleanRef().Body = (IntPtr processHandle, out bool wow64Process) =>
                {
                    wow64Process = true;
                    return true;
                };

                // Act
                var actual = new ULDllImport().Is64BitProcessMessage();

                // Assert
                Assert.AreEqual("This is a 32 bit process!", actual);
            }
        }
Exemplo n.º 3
0
        public void FormatCurrentThreadTimes_on_execute_should_return_expected()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                Stub<OfPULDllImport>.Setup<GetThreadTimesFunc>(_ => _.GetThreadTimesIntPtrInt64RefInt64RefInt64RefInt64Ref()).Body =
                    (IntPtr hThread, out long lpCreationTime, out long lpExitTime, out long lpKernelTime, out long lpUserTime) =>
                    {
                        lpCreationTime = 0;
                        lpExitTime = 1;
                        lpKernelTime = 2;
                        lpUserTime = 3;
                        return true;
                    };


                // Act
                var actual = new ULDllImport().FormatCurrentThreadTimes();


                // Assert
                Assert.AreEqual("Creation Time: 0, Exit Time: 1, Kernel Time: 2, User Time: 3", actual);
            }
        }