Esempio n. 1
0
            public async Task ReleasesAcquiredLeaseOnException()
            {
                var exception = new InvalidOperationException("Fail!");

                ValidationSetProcessor
                .Setup(x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()))
                .Throws(exception);

                var actual = await Assert.ThrowsAsync <InvalidOperationException>(() => Target.HandleAsync(Message));

                Assert.Same(exception, actual);

                VerifyAcquire(Times.Once);
                ValidationSetProcessor.Verify(
                    x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()),
                    Times.Once);
                ValidationOutcomeProcessor.Verify(
                    x => x.ProcessValidationOutcomeAsync(
                        It.IsAny <PackageValidationSet>(),
                        It.IsAny <IValidatingEntity <TestEntity> >(),
                        It.IsAny <ValidationSetProcessorResult>(),
                        It.IsAny <bool>()),
                    Times.Never);
                VerifyRelease(Times.Once);
            }
Esempio n. 2
0
            public async Task SwallowsReleaseException()
            {
                var processorException = new InvalidOperationException("Fail!");

                ValidationSetProcessor
                .Setup(x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()))
                .Throws(processorException);
                var leaseException = new ArgumentException("Release fail!");

                LeaseService
                .Setup(x => x.ReleaseAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()))
                .Throws(leaseException);

                var actual = await Assert.ThrowsAsync <InvalidOperationException>(() => Target.HandleAsync(Message));

                Assert.Same(processorException, actual);

                VerifyAcquire(Times.Once);
                ValidationSetProcessor.Verify(
                    x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()),
                    Times.Once);
                ValidationOutcomeProcessor.Verify(
                    x => x.ProcessValidationOutcomeAsync(
                        It.IsAny <PackageValidationSet>(),
                        It.IsAny <IValidatingEntity <TestEntity> >(),
                        It.IsAny <ValidationSetProcessorResult>(),
                        It.IsAny <bool>()),
                    Times.Never);
                VerifyRelease(Times.Once);
            }
Esempio n. 3
0
            public async Task ReleasesAcquiredLeaseOnSuccess()
            {
                var success = await Target.HandleAsync(Message);

                Assert.True(success);
                VerifyAcquire(Times.Once);
                ValidationSetProcessor.Verify(
                    x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()),
                    Times.Once);
                ValidationOutcomeProcessor.Verify(
                    x => x.ProcessValidationOutcomeAsync(
                        It.IsAny <PackageValidationSet>(),
                        It.IsAny <IValidatingEntity <TestEntity> >(),
                        It.IsAny <ValidationSetProcessorResult>(),
                        It.IsAny <bool>()),
                    Times.Once);
                VerifyRelease(Times.Once);
            }
Esempio n. 4
0
            public async Task DoesNotAcquireLeaseWhenFeatureFlagIsDisabled()
            {
                FeatureFlagService.Setup(x => x.IsOrchestratorLeaseEnabled()).Returns(false);

                var success = await Target.HandleAsync(Message);

                Assert.True(success);
                VerifyAcquire(Times.Never);
                ValidationSetProcessor.Verify(
                    x => x.ProcessValidationsAsync(It.IsAny <PackageValidationSet>()),
                    Times.Once);
                ValidationOutcomeProcessor.Verify(
                    x => x.ProcessValidationOutcomeAsync(
                        It.IsAny <PackageValidationSet>(),
                        It.IsAny <IValidatingEntity <TestEntity> >(),
                        It.IsAny <ValidationSetProcessorResult>(),
                        It.IsAny <bool>()),
                    Times.Once);
                VerifyRelease(Times.Never);
            }