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 ); }
SlinqyQueueShard( IPhysicalQueue physicalQueue) { if (physicalQueue == null) throw new ArgumentNullException(nameof(physicalQueue)); this.PhysicalQueue = physicalQueue; }
SlinqyQueueShard( IPhysicalQueue physicalQueue) { if (physicalQueue == null) { throw new ArgumentNullException(nameof(physicalQueue)); } this.PhysicalQueue = physicalQueue; }
InitializeAgentQueue() { // Create the agent queue. var agentQueueName = this.queueShardMonitor.QueueName + AgentQueueNameSuffix; // Get the agent queue (if it exists). this.agentQueue = (await this.queueService.ListQueues(agentQueueName).ConfigureAwait(false)).SingleOrDefault(); // Create it if it doesn't exist. if (this.agentQueue == null) { this.agentQueue = await this.queueService .CreateQueue(agentQueueName) .ConfigureAwait(false); } // Start reading the queue. this.agentQueue.OnReceive <EvaluateShardsCommand>( async command => await this.EvaluateShards() ); }
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 ); }
InitializeAgentQueue() { // Create the agent queue. var agentQueueName = this.queueShardMonitor.QueueName + AgentQueueNameSuffix; // Get the agent queue (if it exists). this.agentQueue = (await this.queueService.ListQueues(agentQueueName).ConfigureAwait(false)).SingleOrDefault(); // Create it if it doesn't exist. if (this.agentQueue == null) { this.agentQueue = await this.queueService .CreateQueue(agentQueueName) .ConfigureAwait(false); } // Start reading the queue. this.agentQueue.OnReceive<EvaluateShardsCommand>( async command => await this.EvaluateShards() ); }