Exemplo n.º 1
0
        public void BelongsToCurrentProcessAndThreadMatchesOnCurrentProcessAndThread()
        {
            var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
            var fileLock       = new FileLock {
                ProcessId   = currentProcess.Id,
                ProcessName = currentProcess.ProcessName,
                ThreadId    = Thread.CurrentThread.ManagedThreadId,
                Timestamp   = DateTime.Now.Ticks
            };

            Assert.That(fileLock.BelongsToCurrentProcessAndThread(), Is.True);
        }
Exemplo n.º 2
0
        public void BelongsToCurrentProcessAndThreadReturnsFalseIfIncorrectThreadId()
        {
            var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
            var fileLockWithIncorrectThreadId = new FileLock(
                currentProcess.Id,
                currentProcess.ProcessName,
                -200,
                DateTime.Now.Ticks
                );

            Assert.That(fileLockWithIncorrectThreadId.BelongsToCurrentProcessAndThread(), Is.False);
        }
Exemplo n.º 3
0
        public void BelongsToCurrentProcessAndThreadReturnsFalseIfIncorrectProcessId()
        {
            var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
            var fileLockWithIncorrectProcessId = new FileLock
            {
                ProcessId   = -100,
                ProcessName = currentProcess.ProcessName,
                ThreadId    = Thread.CurrentThread.ManagedThreadId,
                Timestamp   = DateTime.Now.Ticks
            };

            Assert.That(fileLockWithIncorrectProcessId.BelongsToCurrentProcessAndThread(), Is.False);
        }