Ejemplo n.º 1
0
        public void NextValueShouldCircleLastBucketWhenDatapoolIsThreadUniqueAndCircularForLastAgentProcessThread()
        {
            SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
            SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
            metadataMock.Setup(md => md.IsCircular).Returns(true);
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            Assert.That(datapool.NextValue(), Is.SameAs(values[47]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[48]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[47]));
        }
Ejemplo n.º 2
0
        public void NextValueShouldThrowExceptionWhenDatapoolIsThreadUniqueAndNonCircularAndAllValuesInLastBucketAreUsedForLastAgentProcessThread()
        {
            SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
            SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
            metadataMock.Setup(md => md.IsCircular).Returns(false);
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            datapool.NextValue();
            datapool.NextValue();
            Assert.Throws(Is.InstanceOf <IllegalStateException>().With.Message.EqualTo("Non circular thread unique datapool 'TestValue' is drained: Agent number '1', process number '2' (TestProcessYYY), thread number '3', run number '4'"), () => datapool.NextValue());
        }
Ejemplo n.º 3
0
        public void NextValueShouldThrowExceptionWhenDatapoolIsThreadSharedAndNonCircularAndAllValuesAreUsed()
        {
            SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
            metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadShared);
            metadataMock.Setup(md => md.IsCircular).Returns(false);
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            datapool.NextValue();
            datapool.NextValue();
            Assert.Throws(Is.InstanceOf <IllegalStateException>().With.Message.EqualTo("Non circular non thread unique datapool 'TestValue' is drained: Agent number '1', process number '2' (TestProcessYYY), thread number '3', run number '4'"), () => datapool.NextValue());
        }
Ejemplo n.º 4
0
        public void NextValueShouldUseAllValuesInCircleWhenDatapoolIsThreadSharedAndCircular()
        {
            metadataMock.Setup(md => md.IsRandom).Returns(false);
            metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadShared);
            metadataMock.Setup(md => md.IsCircular).Returns(true);
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
        }
Ejemplo n.º 5
0
        public void NextValueShouldUseAllValuesInCircleForAllThreadsWhenDatapoolThreadCompleteAndCircular()
        {
            metadataMock.Setup(md => md.IsRandom).Returns(false);
            metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadComplete);
            metadataMock.Setup(md => md.IsCircular).Returns(true);
            grinderContextMock.Setup(c => c.GetProperty(Constants.AgentCountKey, "1")).Returns("1");
            grinderContextMock.Setup(c => c.GetProperty(Constants.ProcessCountKey, "1")).Returns("1");
            grinderContextMock.Setup(c => c.GetProperty(Constants.ThreadCountKey, "1")).Returns("2");
            grinderContextMock.Setup(gc => gc.AgentNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.FirstProcessNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.ProcessNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.ProcessName).Returns("TestProcessYYY");
            grinderContextMock.Setup(gc => gc.RunNumber).Returns(1);
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(0);
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));

            grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(1);
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
        }
Ejemplo n.º 6
0
        public void NextValueShouldThrowExceptionWhenDatapoolIsThreadUniqueAndThreadNumberIsNotLessThanThreadCount()
        {
            SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
            var datapool = new Datapool <TestValue>(grinderContextMock.Object, metadataMock.Object);

            grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(4);
            Assert.Throws(Is.InstanceOf <IllegalStateException>().With.Message.EqualTo("ThreadNumber '4' is not less than property 'grinder.threads': '4'"), () => datapool.NextValue());
        }
Ejemplo n.º 7
0
        public void NextValueShouldUseAllValuesInCircleForAllThreadsWhenDatapoolThreadCompleteAndCircular()
        {
            metadataMock.Setup(md => md.IsRandom).Returns(false);
            metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadComplete);
            metadataMock.Setup(md => md.IsCircular).Returns(true);
            grinderContextMock.Setup(c => c.GetProperty(Constants.AgentCountKey, "1")).Returns("1");
            grinderContextMock.Setup(c => c.GetProperty(Constants.ProcessCountKey, "1")).Returns("1");
            grinderContextMock.Setup(c => c.GetProperty(Constants.ThreadCountKey, "1")).Returns("2");
            grinderContextMock.Setup(gc => gc.AgentNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.FirstProcessNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.ProcessNumber).Returns(0);
            grinderContextMock.Setup(gc => gc.ProcessName).Returns("TestProcessYYY");
            grinderContextMock.Setup(gc => gc.RunNumber).Returns(1);
            var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);

            grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(0);
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));

            grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(1);
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
            Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
        }
Ejemplo n.º 8
0
 public void NextValueShouldThrowExceptionWhenDatapoolIsThreadUniqueAndNonCircularAndAllValuesInLastBucketAreUsedForLastAgentProcessThread()
 {
     SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
     SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
     metadataMock.Setup(md => md.IsCircular).Returns(false);
     var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);
     datapool.NextValue();
     datapool.NextValue();
     Assert.Throws(Is.InstanceOf<IllegalStateException>().With.Message.EqualTo("Non circular thread unique datapool 'TestValue' is drained: Agent number '1', process number '2' (TestProcessYYY), thread number '3', run number '4'"), () => datapool.NextValue());
 }
Ejemplo n.º 9
0
 public void NextValueShouldCircleLastBucketWhenDatapoolIsThreadUniqueAndCircularForLastAgentProcessThread()
 {
     SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
     SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
     metadataMock.Setup(md => md.IsCircular).Returns(true);
     var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);
     Assert.That(datapool.NextValue(), Is.SameAs(values[47]));
     Assert.That(datapool.NextValue(), Is.SameAs(values[48]));
     Assert.That(datapool.NextValue(), Is.SameAs(values[47]));
 }
Ejemplo n.º 10
0
 public void NextValueShouldThrowExceptionWhenDatapoolIsThreadUniqueAndThreadNumberIsNotLessThanThreadCount()
 {
     SetupThreadUniqueContextFor2Agents3Processes4ThreadsAnd49TestValues();
     var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);
     grinderContextMock.Setup(gc => gc.ThreadNumber).Returns(4);
     Assert.Throws(Is.InstanceOf<IllegalStateException>().With.Message.EqualTo("ThreadNumber '4' is not less than property 'grinder.threads': '4'"), () => datapool.NextValue());
 }
Ejemplo n.º 11
0
 public void NextValueShouldThrowExceptionWhenDatapoolIsThreadSharedAndNonCircularAndAllValuesAreUsed()
 {
     SetupContextForAgentNumber1ProcessNumber2ThreadNumber3RunNumber4();
     metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadShared);
     metadataMock.Setup(md => md.IsCircular).Returns(false);
     var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);
     datapool.NextValue();
     datapool.NextValue();
     Assert.Throws(Is.InstanceOf<IllegalStateException>().With.Message.EqualTo("Non circular non thread unique datapool 'TestValue' is drained: Agent number '1', process number '2' (TestProcessYYY), thread number '3', run number '4'"), () => datapool.NextValue());
 }
Ejemplo n.º 12
0
 public void NextValueShouldUseAllValuesInCircleWhenDatapoolIsThreadSharedAndCircular()
 {
     metadataMock.Setup(md => md.IsRandom).Returns(false);
     metadataMock.Setup(md => md.DistributionMode).Returns(DatapoolThreadDistributionMode.ThreadShared);
     metadataMock.Setup(md => md.IsCircular).Returns(true);
     var datapool = new Datapool<TestValue>(grinderContextMock.Object, metadataMock.Object);
     Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
     Assert.That(datapool.NextValue(), Is.SameAs(values[1]));
     Assert.That(datapool.NextValue(), Is.SameAs(values[0]));
 }