Exemple #1
0
        public async Task CannotTakeLockWhenAlreadyActivated()
        {
            var activator = GetFakeActivator();
            var timeout   = new CancellationTokenSource(1000).Token;
            var identity  = new ClusterIdentity {
                Kind = "thing", Identity = NextId().ToString()
            };
            var spawnLock = await _storage.TryAcquireLock(identity, timeout);

            var pid = Activate(activator, identity);
            await _storage.StoreActivation(activator.Id, spawnLock !, pid, timeout);

            var activation = await _storage.TryGetExistingActivation(identity, timeout);

            activation.Should().NotBeNull();
            activation !.MemberId.Should().Be(activator.Id);
            activation !.Pid.Should().BeEquivalentTo(pid);

            var noLock = await _storage.TryAcquireLock(identity, timeout);

            noLock.Should().BeNull("Since the activation is active, it should not be possible to take the lock");
        }