Beispiel #1
0
 public void InitializeShouldLogFirstAndLastElementAndRandom()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.TrueString);
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("seed"), It.IsAny <string>())).Returns("345");
     scenaroio.Initialize();
     loggerMock.Verify(l => l.Info("OnInitialize: FirstElement = 1, LastElement = 100, IsRandom = True, Seed = 345"));
 }
Beispiel #2
0
 public void InitializeShouldInitializeSeedFromPropertyWhenProvided()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.TrueString);
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("seed"), It.IsAny <string>())).Returns("543");
     scenaroio.Initialize();
     Assert.That(scenaroio.Seed, Is.EqualTo(543));
 }
Beispiel #3
0
 public void InitializeShouldLogWorkerInfoForAllUnderlyingWorkers()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.FalseString);
     SetupTestWorkers();
     scenaroio.Initialize();
     loggerMock.Verify(l => l.Info("Worker[1] = 'GrinderScript.Net.Core.UnitTests.Framework.ScenarioWorkerTests+TestWorker1'"));
     loggerMock.Verify(l => l.Info("Worker[2] = 'GrinderScript.Net.Core.UnitTests.Framework.ScenarioWorkerTests+TestWorker2'"));
     loggerMock.Verify(l => l.Info("Worker[3] = 'GrinderScript.Net.Core.UnitTests.Framework.ScenarioWorkerTests+TestWorker100'"));
 }
Beispiel #4
0
        public void ShutdownShouldRetrowUnderlyingExceptions()
        {
            SetupTestWorkers();
            SetupTestWorkersWithShutdownExceptions();
            contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.FalseString);
            scenaroio.Initialize();
            var exception = Assert.Throws <AggregateException>(() => scenaroio.Shutdown());

            Assert.That(exception.InnerExceptions.Count, Is.EqualTo(2));
            Assert.That(exception.InnerExceptions[0], Is.InstanceOf <InvalidOperationException>());
            Assert.That(exception.InnerExceptions[1], Is.InstanceOf <ApplicationException>());
        }
Beispiel #5
0
 public void RunShouldRunAllWorkersWhenRunningRandomly()
 {
     SetupTestWorkers();
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.TrueString);
     scenaroio.Initialize();
     scenaroio.Run();
     foreach (var underlying in scenaroio.Group)
     {
         Assert.IsInstanceOf <TestWorker>(underlying);
         Assert.That(((TestWorker)underlying).OnRunIsCalled);
         Assert.That(((TestWorker)underlying).OnRunCallCount, Is.EqualTo(1));
     }
 }
Beispiel #6
0
 public void FirstElementPropertyShouldBeGreaterThanZero()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("firstElement"), "1")).Returns("0");
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Property 'grinderscript-dotnet.scenarioWorker.firstElement' should be > 0, but was 0"), () => scenaroio.Initialize());
 }
Beispiel #7
0
 public void InitializeShouldInitializeSeedWhenRandomPropertyIsNotFalse()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.TrueString);
     scenaroio.Initialize();
     Assert.That(scenaroio.Seed, Is.Not.EqualTo(0));
 }
Beispiel #8
0
 public void InitializeShouldNotInitializeRandomWhenRandomPropertyIsFalse()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.FalseString);
     scenaroio.Initialize();
     Assert.That(scenaroio.Random, Is.Null);
 }
Beispiel #9
0
 public void InitializeShouldUseRandomValueWhenRandomPropertyIsProvided()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("random"), It.IsAny <string>())).Returns(bool.FalseString);
     scenaroio.Initialize();
     Assert.That(scenaroio.IsRandom, Is.False);
 }
Beispiel #10
0
 public void LastElementPropertyShouldBeNotBeLessThanFirstElement()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("lastElement"), "100")).Returns("0");
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Property 'grinderscript-dotnet.scenarioWorker.lastElement' can not be < 'grinderscript-dotnet.scenarioWorker.firstElement' (1), but was 0"), () => scenaroio.Initialize());
 }
Beispiel #11
0
 public void InitializeShouldUseLastElementValueWhenPropertyIsProvided()
 {
     contextMock.Setup(c => c.GetProperty(ScenarioWorker.GetPropertyKey("lastElement"), "100")).Returns("3");
     scenaroio.Initialize();
     contextMock.Verify(c => c.GetProperty(ScenarioWorker.GetElementPropertyKey(100, "workerType")), Times.Never());
 }