public void ChangesCurrentTransmissionStorageCapacityImmediatelyWhenNoOverridingPoliciesAreInEffect() { var storage = new StubTransmissionStorage(); Transmitter transmitter = CreateTransmitter(storage: storage); transmitter.ApplyPolicies(); transmitter.MaxStorageCapacity = 42; Assert.Equal(42, storage.Capacity); }
public void ChangesCurrentTransmissionSenderCapacityImmediatelyWhenNoOverridingPoliciesAreInEffect() { var sender = new StubTransmissionSender(); Transmitter transmitter = CreateTransmitter(sender: sender); transmitter.ApplyPolicies(); transmitter.MaxSenderCapacity = 42; Assert.Equal(42, sender.Capacity); }
public void ChangesCurrentBufferCapacityImmediatelyWhenNoOverridingPoliciesAreInEffect() { var buffer = new StubTransmissionBuffer(); Transmitter transmitter = CreateTransmitter(buffer: buffer); transmitter.ApplyPolicies(); transmitter.MaxBufferCapacity = 42; Assert.AreEqual(42, buffer.Capacity); }
public void DoesNotApplyPolicesIfTheyAlreadyApplied() { var senderPolicy = new StubTransmissionPolicy { MaxSenderCapacity = 0 }; var sender = new StubTransmissionSender(); Transmitter transmitter = CreateTransmitter(sender: sender, policies: new[] { senderPolicy }); transmitter.ApplyPolicies(); senderPolicy.MaxSenderCapacity = 2; transmitter.Enqueue(new StubTransmission()); Assert.NotEqual(senderPolicy.MaxSenderCapacity, sender.Capacity); }
public async Task DoesNotApplyPolicesIfTheyAlreadyApplied() { var senderPolicy = new StubTransmissionPolicy { MaxSenderCapacity = 0 }; var sender = new StubTransmissionSender(); Transmitter transmitter = CreateTransmitter(sender: sender, policies: new[] { senderPolicy }); transmitter.ApplyPolicies(); senderPolicy.MaxSenderCapacity = 2; var result = await transmitter.FlushAsync(new StubTransmission(), default); Assert.AreNotEqual(senderPolicy.MaxSenderCapacity, sender.Capacity); Assert.IsTrue(result); }
public void MovesTransmissionsFromStorageToSenderToAvoidWaitingUntilBufferIsFullBeforeSendingStarts() { var storedTransmission = new StubTransmission(); var storage = new StubTransmissionStorage(); storage.Enqueue(() => storedTransmission); var buffer = new StubTransmissionBuffer(); var sentTransmissions = new List <Transmission>(); StubTransmissionSender sender = CreateSender(sentTransmissions); sender.OnGetCapacity = () => 1; Transmitter transmitter = CreateTransmitter(sender, buffer, storage); transmitter.ApplyPolicies(); Assert.Contains(storedTransmission, sentTransmissions); }
public void SetsStorageCapacityToMinValueReturnedByTransmissionPolicies() { var storage = new StubTransmissionStorage(); var policies = new[] { new StubTransmissionPolicy { MaxStorageCapacity = 4 }, new StubTransmissionPolicy { MaxStorageCapacity = 2 }, }; Transmitter transmitter = CreateTransmitter(storage: storage, policies: policies); transmitter.ApplyPolicies(); Assert.Equal(2, storage.Capacity); }
public void SetsBufferCapacityToMinValueReturnedByTransmissionPolicies() { var buffer = new StubTransmissionBuffer(); var policies = new[] { new StubTransmissionPolicy { MaxBufferCapacity = 4 }, new StubTransmissionPolicy { MaxBufferCapacity = 2 }, }; Transmitter transmitter = CreateTransmitter(buffer: buffer, policies: policies); transmitter.ApplyPolicies(); Assert.Equal(2, buffer.Capacity); }
public void SetsSenderCapacityToMinValueReturnedByTransmissionPolicies() { var sender = new StubTransmissionSender(); var policies = new[] { new StubTransmissionPolicy { MaxSenderCapacity = 4 }, new StubTransmissionPolicy { MaxSenderCapacity = 2 }, }; Transmitter transmitter = CreateTransmitter(sender: sender, policies: policies); transmitter.ApplyPolicies(); Assert.AreEqual(2, sender.Capacity); }
public void DoesNotMoveTransmissionsFromStorageToSenderWhenBufferIsNotEmptyToPreserveQueueOrder() { var storedTransmission = new StubTransmission(); var storage = new StubTransmissionStorage(); storage.Enqueue(() => storedTransmission); var buffer = new StubTransmissionBuffer { OnGetSize = () => 1 }; var sentTransmissions = new List <Transmission>(); StubTransmissionSender sender = CreateSender(sentTransmissions); sender.OnGetCapacity = () => 1; Transmitter transmitter = CreateTransmitter(sender, buffer, storage); transmitter.ApplyPolicies(); Assert.DoesNotContain(storedTransmission, sentTransmissions); }