Beispiel #1
0
        SlinqyAgentTests()
        {
            // Configures one read/writable shard since that's the minimum valid state.
            this.fakeShard = this.CreateFakeSendReceiveQueue();

            // Configures the fake shard monitor to use the fake shards.
            this.fakeQueueShardMonitor = A.Fake <SlinqyQueueShardMonitor>();
            this.fakeShards            = new List <SlinqyQueueShard> {
                this.fakeShard
            };

            // Configures the fake agent queue to use.
            this.fakeAgentQueue = CreateFakeAgentQueue();

            A.CallTo(() => this.fakeQueueService.CreateQueue(ValidSlinqyAgentName)).Returns(this.fakeAgentQueue);
            A.CallTo(() => this.fakeAgentQueue.OnReceive(A <Func <EvaluateShardsCommand, Task> > .Ignored)).Invokes(call =>
            {
                this.agentEvaluateShardsCommandHandler = call.GetArgument <Func <EvaluateShardsCommand, Task> >(0);
            });

            A.CallTo(() => this.fakeQueueShardMonitor.SendShard).Returns(this.fakeShard);
            A.CallTo(() => this.fakeQueueShardMonitor.QueueName).Returns(ValidSlinqyQueueName);
            A.CallTo(() => this.fakeQueueShardMonitor.Shards).Returns(this.fakeShards);

            // Configure the agent that will be tested.
            this.slinqyAgent = new SlinqyAgent(
                queueService:                       this.fakeQueueService,
                slinqyQueueShardMonitor:            this.fakeQueueShardMonitor,
                storageCapacityScaleOutThreshold:   ValidStorageCapacityScaleOutThreshold
                );
        }
Beispiel #2
0
        GenerateNextShardName_ZeroPaddedShardName_ReturnsIncrementedShardNameWithMatchingPadding()
        {
            // Arrange
            const string ExistingShardName = ValidSlinqyQueueName + "0001";

            // Act
            var actual = SlinqyQueueShard.GenerateNextShardName(ExistingShardName);

            // Assert
            Assert.Equal(ValidSlinqyQueueName + "0002", actual);
        }
Beispiel #3
0
        GenerateFirstShardName_MultipleShardIndexPaddingIsSpecified_ReturnsCorrectName()
        {
            // Arrange
            const int ShardIndexPadding = 2;

            // Act
            var actual = SlinqyQueueShard.GenerateFirstShardName(ValidSlinqyQueueName, ShardIndexPadding);

            // Assert
            Assert.Equal(ValidSlinqyQueueName + "00", actual);
        }
Beispiel #4
0
        SlinqyAgentTests()
        {
            // Configures one read/writable shard since that's the minimum valid state.
            this.fakeShard = this.CreateFakeSendReceiveQueue();

            // Configures the fake shard monitor to use the fake shards.
            this.fakeQueueShardMonitor = A.Fake<SlinqyQueueShardMonitor>();
            this.fakeShards = new List<SlinqyQueueShard> { this.fakeShard };

            A.CallTo(() => this.fakeQueueShardMonitor.SendShard).Returns(this.fakeShard);
            A.CallTo(() => this.fakeQueueShardMonitor.QueueName).Returns(ValidSlinqyQueueName);
            A.CallTo(() => this.fakeQueueShardMonitor.Shards).Returns(this.fakeShards);

            // Configure the agent that will be tested.
            this.slinqyAgent = new SlinqyAgent(
                queueService:                       this.fakeQueueService,
                slinqyQueueShardMonitor:            this.fakeQueueShardMonitor,
                storageCapacityScaleOutThreshold:   ValidStorageCapacityScaleOutThreshold
            );
        }
        SlinqyQueueTests()
        {
            this.fakeReceiveShard   = A.Fake<SlinqyQueueShard>();
            this.fakeSendShard      = A.Fake<SlinqyQueueShard>();

            A.CallTo(() => this.fakeReceiveShard.PhysicalQueue.IsSendEnabled).Returns(false);
            A.CallTo(() => this.fakeSendShard.PhysicalQueue.IsSendEnabled).Returns(true);

            var shards = new List<SlinqyQueueShard> {
                this.fakeReceiveShard,
                this.fakeSendShard
            };

            A.CallTo(() => this.fakeQueueShardMonitor.Shards).Returns(shards);
            A.CallTo(() => this.fakeQueueShardMonitor.SendShard).Returns(this.fakeSendShard);
            A.CallTo(() => this.fakeQueueShardMonitor.ReceiveShard).Returns(this.fakeReceiveShard);

            this.slinqyQueue = new SlinqyQueue(
                this.fakeQueueShardMonitor
            );
        }
Beispiel #6
0
        SlinqyQueueTests()
        {
            this.fakeReceiveShard = A.Fake <SlinqyQueueShard>();
            this.fakeSendShard    = A.Fake <SlinqyQueueShard>();

            A.CallTo(() => this.fakeReceiveShard.PhysicalQueue.IsSendEnabled).Returns(false);
            A.CallTo(() => this.fakeSendShard.PhysicalQueue.IsSendEnabled).Returns(true);

            var shards = new List <SlinqyQueueShard> {
                this.fakeReceiveShard,
                this.fakeSendShard
            };

            A.CallTo(() => this.fakeQueueShardMonitor.Shards).Returns(shards);
            A.CallTo(() => this.fakeQueueShardMonitor.SendShard).Returns(this.fakeSendShard);
            A.CallTo(() => this.fakeQueueShardMonitor.ReceiveShard).Returns(this.fakeReceiveShard);

            this.slinqyQueue = new SlinqyQueue(
                this.fakeQueueShardMonitor
                );
        }
        SlinqyQueueShardTests()
        {
            A.CallTo(() => this.fakePhysicalQueue.Name).Returns(ValidSlinqyShardName);

            this.slinqyQueueShard = new SlinqyQueueShard(this.fakePhysicalQueue);
        }
        SlinqyAgentTests()
        {
            // Configures one read/writable shard since that's the minimum valid state.
            this.fakeShard = this.CreateFakeSendReceiveQueue();

            // Configures the fake shard monitor to use the fake shards.
            this.fakeQueueShardMonitor = A.Fake<SlinqyQueueShardMonitor>();
            this.fakeShards = new List<SlinqyQueueShard> { this.fakeShard };

            // Configures the fake agent queue to use.
            this.fakeAgentQueue = CreateFakeAgentQueue();

            A.CallTo(() => this.fakeQueueService.CreateQueue(ValidSlinqyAgentName)).Returns(this.fakeAgentQueue);
            A.CallTo(() => this.fakeAgentQueue.OnReceive(A<Func<EvaluateShardsCommand, Task>>.Ignored)).Invokes(call =>
            {
                this.agentEvaluateShardsCommandHandler = call.GetArgument<Func<EvaluateShardsCommand, Task>>(0);
            });

            A.CallTo(() => this.fakeQueueShardMonitor.SendShard).Returns(this.fakeShard);
            A.CallTo(() => this.fakeQueueShardMonitor.QueueName).Returns(ValidSlinqyQueueName);
            A.CallTo(() => this.fakeQueueShardMonitor.Shards).Returns(this.fakeShards);

            // Configure the agent that will be tested.
            this.slinqyAgent = new SlinqyAgent(
                queueService:                       this.fakeQueueService,
                slinqyQueueShardMonitor:            this.fakeQueueShardMonitor,
                storageCapacityScaleOutThreshold:   ValidStorageCapacityScaleOutThreshold
            );
        }
Beispiel #9
0
        SlinqyQueueShardTests()
        {
            A.CallTo(() => this.fakePhysicalQueue.Name).Returns(ValidSlinqyShardName);

            this.slinqyQueueShard = new SlinqyQueueShard(this.fakePhysicalQueue);
        }