public void ReleaseLockHeldByGSD_WhenNoLock()
        {
            Mock <ITracer> mockTracer = new Mock <ITracer>(MockBehavior.Strict);
            GSDLock        gvfsLock   = new GSDLock(mockTracer.Object);

            this.ValidateLockIsFree(gvfsLock);
            Assert.Throws <InvalidOperationException>(() => gvfsLock.ReleaseLockHeldByGSD());
            mockTracer.VerifyAll();
        }
        public void ReleaseLockHeldByGSD_WhenExternalHasLockShouldThrow()
        {
            Mock <ITracer> mockTracer = new Mock <ITracer>(MockBehavior.Strict);

            mockTracer.Setup(x => x.RelatedEvent(EventLevel.Informational, "TryAcquireLockExternal", It.IsAny <EventMetadata>()));
            MockPlatform mockPlatform = (MockPlatform)GSDPlatform.Instance;
            GSDLock      gvfsLock     = this.AcquireDefaultLock(mockPlatform, mockTracer.Object);

            Assert.Throws <InvalidOperationException>(() => gvfsLock.ReleaseLockHeldByGSD());
            mockTracer.VerifyAll();
        }
        public void TryAcquireLockForGSD()
        {
            Mock <ITracer> mockTracer = new Mock <ITracer>(MockBehavior.Strict);

            mockTracer.Setup(x => x.RelatedEvent(EventLevel.Verbose, "TryAcquireLockInternal", It.IsAny <EventMetadata>()));
            mockTracer.Setup(x => x.RelatedEvent(EventLevel.Verbose, "ReleaseLockHeldByGSD", It.IsAny <EventMetadata>()));
            GSDLock gvfsLock = this.AcquireGSDLock(mockTracer.Object);

            // Should be able to call again when GSD has the lock
            gvfsLock.TryAcquireLockForGSD().ShouldBeTrue();
            this.ValidateLockHeldByGSD(gvfsLock);

            gvfsLock.ReleaseLockHeldByGSD();
            this.ValidateLockIsFree(gvfsLock);
            mockTracer.VerifyAll();
        }