public async Task UnexpectedMessage_During_StartProcessing_Handled() { //Arrange var uri = new Uri(@"test://"); var packetBatch = new PacketBatch(this._loadBalancerSettings.BatchSize); packetBatch.Add(new RawPacket()); this._batchLoaderMock.Setup(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize)) .Returns(() => Task.Run(() => packetBatch)); this._offlineLoadBalancerActorRefSUT.Tell(new CaptureProcessingRequest { CaptureInfo = new CaptureInfo(uri) }); await Task.Delay(50); //Act this._offlineLoadBalancerActorRefSUT.Tell(new CaptureProcessingRequest { CaptureInfo = new CaptureInfo(uri) }); //Assert await Task.Delay(50); this._batchLoaderMock.Verify(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize), Times.Once); this._batchSenderMock.Verify(sender => sender.SendBatch(packetBatch), Times.Once); //TODO test that error message was logged }
public async Task LoadBatch_DataLoaded_SendPacketBatch() { //Arrange var uri = new Uri(@"test://"); var packetBatch = new PacketBatch(this._loadBalancerSettings.BatchSize); packetBatch.Add(new RawPacket()); this._batchLoaderMock.Setup(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize)) .Returns(() => Task.Run(() => packetBatch)); //Act this._offlineLoadBalancerActorRefSUT.Tell(new CaptureProcessingRequest { CaptureInfo = new CaptureInfo(uri) }); //Assert await Task.Delay(50); this._batchLoaderMock.Verify(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize), Times.Once); this._batchSenderMock.Verify(sender => sender.SendBatch(packetBatch), Times.Once); }
public async Task LoadBatch_DataLoaded_Send_Acknowledged_SendFinish() { //Arrange var uri = new Uri(@"test://"); var packetBatchWithOnePacker = new PacketBatch(this._loadBalancerSettings.BatchSize); packetBatchWithOnePacker.Add(new RawPacket()); var packetBatchEmpty = new PacketBatch(this._loadBalancerSettings.BatchSize); this._batchLoaderMock.Setup(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize)) .Returns(() => Task.Run(() => packetBatchWithOnePacker)); this._batchSenderMock.Setup(sender => sender.DistributedPackets).Returns(1); //Act this._offlineLoadBalancerActorRefSUT.Tell(new CaptureProcessingRequest { CaptureInfo = new CaptureInfo(uri) }); await Task.Delay(50); this._batchLoaderMock.Setup(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize)) .Returns(() => Task.Run(() => packetBatchEmpty)); this._offlineLoadBalancerActorRefSUT.Tell(new RawPacketBatchAck()); //Assert await Task.Delay(50); this._batchLoaderMock.Verify(loader => loader.LoadBatch(this._loadBalancerSettings.BatchSize), Times.Exactly(2)); this._batchSenderMock.Verify(sender => sender.SendBatch(packetBatchWithOnePacker), Times.Once); var processingResult = this.ExpectMsg <ProcessingResult>(); Assert.True(processingResult.Success); Assert.Equal((UInt64)1, processingResult.ProcessedPackets); }