Esempio n. 1
0
        public void Provided_RequestStrategies_should_implement_MaxInFlight_with_batchSize_max_correctly()
        {
            var queue = new List <string>();
            var strat = new InFlightWithBatchSize(max: 3, queue: queue, batchSize: 5);  //will be bounded to max

            strat.RequestDemand(0).Should().Be(3);
            queue.Add("a");
            strat.RequestDemand(2).Should().Be(0);
            queue.Add("b");
            strat.RequestDemand(1).Should().Be(0);
            queue.Add("c");
            strat.RequestDemand(0).Should().Be(0);
            queue.Remove("a");
            strat.RequestDemand(0).Should().Be(0);
            queue.Remove("b");
            strat.RequestDemand(0).Should().Be(0);
            queue.Remove("c");
            strat.RequestDemand(0).Should().Be(3);
        }
Esempio n. 2
0
 public void Provided_RequestStragies_should_implement_MaxInFlight_with_batchSize_3_correctly()
 {
     var queue = new List<string>();
     var strat = new InFlightWithBatchSize(10, queue, 3);
     strat.RequestDemand(0).Should().Be(10);
     queue.Add("a");
     strat.RequestDemand(9).Should().Be(0);
     queue.Add("b");
     strat.RequestDemand(8).Should().Be(0);
     queue.Add("c");
     strat.RequestDemand(7).Should().Be(0);
     queue.Add("d");
     strat.RequestDemand(6).Should().Be(0);
     queue.Remove("a"); //3 remaining in queue
     strat.RequestDemand(6).Should().Be(0);
     queue.Remove("b"); //2 remaining in queue
     strat.RequestDemand(6).Should().Be(0);
     queue.Remove("c"); //1 remaining in queue
     strat.RequestDemand(6).Should().Be(3);
 }
Esempio n. 3
0
        public void Provided_RequestStrategies_should_implement_MaxInFlight_with_batchSize_3_correctly()
        {
            var queue = new List <string>();
            var strat = new InFlightWithBatchSize(10, queue, 3);

            strat.RequestDemand(0).Should().Be(10);
            queue.Add("a");
            strat.RequestDemand(9).Should().Be(0);
            queue.Add("b");
            strat.RequestDemand(8).Should().Be(0);
            queue.Add("c");
            strat.RequestDemand(7).Should().Be(0);
            queue.Add("d");
            strat.RequestDemand(6).Should().Be(0);
            queue.Remove("a"); //3 remaining in queue
            strat.RequestDemand(6).Should().Be(0);
            queue.Remove("b"); //2 remaining in queue
            strat.RequestDemand(6).Should().Be(0);
            queue.Remove("c"); //1 remaining in queue
            strat.RequestDemand(6).Should().Be(3);
        }
Esempio n. 4
0
 public void Provided_RequestStragies_should_implement_MaxInFlight_with_batchSize_1_correctly()
 {
     var queue = new List<string>();
     var strat = new InFlightWithBatchSize(10, queue, 1);
     strat.RequestDemand(0).Should().Be(10);
     strat.RequestDemand(9).Should().Be(1);
     queue.Add("a");
     strat.RequestDemand(0).Should().Be(9);
     strat.RequestDemand(8).Should().Be(1);
     strat.RequestDemand(9).Should().Be(0);
     queue.Add("b");
     queue.Add("c");
     strat.RequestDemand(5).Should().Be(2);
     queue.AddRange(new []{"d", "e", "f", "g", "h", "i", "j"});
     queue.Count.Should().Be(10);
     strat.RequestDemand(0).Should().Be(0);
     strat.RequestDemand(1).Should().Be(0);
     queue.Add("g");
     strat.RequestDemand(0).Should().Be(0);
     strat.RequestDemand(1).Should().Be(0);
 }
Esempio n. 5
0
        public void Provided_RequestStrategies_should_implement_MaxInFlight_with_batchSize_1_correctly()
        {
            var queue = new List <string>();
            var strat = new InFlightWithBatchSize(10, queue, 1);

            strat.RequestDemand(0).Should().Be(10);
            strat.RequestDemand(9).Should().Be(1);
            queue.Add("a");
            strat.RequestDemand(0).Should().Be(9);
            strat.RequestDemand(8).Should().Be(1);
            strat.RequestDemand(9).Should().Be(0);
            queue.Add("b");
            queue.Add("c");
            strat.RequestDemand(5).Should().Be(2);
            queue.AddRange(new [] { "d", "e", "f", "g", "h", "i", "j" });
            queue.Count.Should().Be(10);
            strat.RequestDemand(0).Should().Be(0);
            strat.RequestDemand(1).Should().Be(0);
            queue.Add("g");
            strat.RequestDemand(0).Should().Be(0);
            strat.RequestDemand(1).Should().Be(0);
        }
Esempio n. 6
0
 public void Provided_RequestStragies_should_implement_MaxInFlight_with_batchSize_max_correctly()
 {
     var queue = new List<string>();
     var strat = new InFlightWithBatchSize(max: 3, queue: queue, batchSize: 5 ); //will be bounded to max
     strat.RequestDemand(0).Should().Be(3);
     queue.Add("a");
     strat.RequestDemand(2).Should().Be(0);
     queue.Add("b");
     strat.RequestDemand(1).Should().Be(0);
     queue.Add("c");
     strat.RequestDemand(0).Should().Be(0);
     queue.Remove("a");
     strat.RequestDemand(0).Should().Be(0);
     queue.Remove("b");
     strat.RequestDemand(0).Should().Be(0);
     queue.Remove("c");
     strat.RequestDemand(0).Should().Be(3);
 }