public void CreateDatapoolShouldAskDatapoolManagerToBuildDatapoolWithCorrectProperties() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("valueType"))).Returns(typeof(TestValue).FullName); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("factoryType"))).Returns(typeof(TestValueFactory <>).FullName); datapoolFactoy.CreateDatapool <TestValue>(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.IsAny <IDatapoolMetatdata <TestValue> >())); }
public void CreateMissingDatapoolsFromPropertiesShouldCheckNameWithDatapoolManager() { const string DatapoolName = "TestPoolName1"; grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("1"))).Returns(DatapoolName); datapoolManagerMock.Setup(dm => dm.ContainsDatapool(DatapoolName)).Returns(true).Verifiable(); datapoolFactoy.CreateMissingDatapoolsFromProperties(); datapoolManagerMock.Verify(); }
public void CreateMissingDatapoolsFromPropertiesShouldThrowExceptionWhenValueTypenNamePropertyIsMissing() { const string DatapoolName = "TestPoolName4"; grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("4"))).Returns(DatapoolName); datapoolManagerMock.Setup(dm => dm.ContainsDatapool(DatapoolName)).Returns(false); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey(DatapoolName, "valueType"))).Returns <string>(null); Assert.Throws(Is.InstanceOf <ArgumentException>().With.Message.EqualTo("Missing property 'grinderscript-dotnet.datapool.TestPoolName4.valueType'"), () => datapoolFactoy.CreateMissingDatapoolsFromProperties()); }
public void CreateMissingDatapoolsFromPropertiesShouldNotAddExistingDatapoolToDatapoolManager() { const string DatapoolName = "TestPoolName3"; grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("3"))).Returns(DatapoolName); datapoolManagerMock.Setup(dm => dm.ContainsDatapool(DatapoolName)).Returns(true); datapoolFactoy.CreateMissingDatapoolsFromProperties(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.IsAny <IDatapoolMetatdata <TestValue> >()), Times.Never()); }
public void SetUp() { grinderContextMock = TestUtils.CreateContextMock(); grinderContextMock.Setup(c => c.ScriptFile).Returns(TestUtils.TestsAsScriptFile); datapoolManagerMock = new Mock <IDatapoolManager>(); datapoolFactoy = new DatapoolFactory(grinderContextMock.Object, datapoolManagerMock.Object); testValues = new List <TestValue> { new TestValue() }; }
public void InitializeShouldCreateMissingDatapoolsFromProperties() { const string DatapoolName = "TestPoolName2"; contextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("2"))).Returns(DatapoolName); contextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey(DatapoolName, "valueType"))).Returns(typeof(DatapoolFactoryTests.TestValue).FullName); contextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey(DatapoolName, "factoryType"))).Returns(typeof(DatapoolFactoryTests.TestValueFactory <>).FullName); InitializeBridgeWithTestScriptEngine(); Assert.That(bridge.ProcessContext.DatapoolManager.ContainsDatapool("TestPoolName2")); }
public void CreateMissingDatapoolsFromPropertiesShouldAddNonExitingDatapoolToDatapoolManager() { const string DatapoolName = "TestPoolName2"; grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("2"))).Returns(DatapoolName); datapoolManagerMock.Setup(dm => dm.ContainsDatapool(DatapoolName)).Returns(false); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey(DatapoolName, "valueType"))).Returns(typeof(TestValue).FullName); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey(DatapoolName, "factoryType"))).Returns(typeof(TestValueFactory <>).FullName); datapoolFactoy.CreateMissingDatapoolsFromProperties(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.IsAny <IDatapoolMetatdata <TestValue> >())); }
public void CreateValuesShouldUseCsvFileFromProperty() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValues>("csvFile"), "TestValues.csv")).Returns("TestValuesCsvFileWithADifferentNameThanTheType.csv"); var actual = factory.CreateValues(grinderContextMock.Object); Assert.That(actual.Count == 1); var value1 = actual[0]; Assert.That(value1.StringProp1 == "StringProp1;"); Assert.That(value1.StringProp2 == "stringprop2"); Assert.That(value1.IntProp == 23); Assert.That(value1.LongProp == 234); Assert.That(value1.BoolProp); }
public IList <T> CreateValues(IGrinderContext grinderContext, string name) { if (grinderContext == null) { throw new ArgumentNullException("grinderContext"); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } string fileName = grinderContext.GetProperty(DatapoolFactory.GetPropertyKey(name, "csvFile"), string.Format("{0}.csv", name)); return(CreateValues(fileName)); }
public void CreateMissingDatapoolsFromPropertiesShouldUseLastElementValueWhenPropertyIsProvided() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("lastElement"), "100")).Returns("3"); datapoolFactoy.CreateMissingDatapoolsFromProperties(); grinderContextMock.Verify(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("100")), Times.Never()); }
public void CreateDatapoolShouldThrowExceptionWhenValueTypeNamePropertyIsWrong() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("valueType"))).Returns(typeof(DatapoolFactoryTests).FullName); Assert.Throws(Is.InstanceOf <ArgumentException>().With.Message.EqualTo("Type 'GrinderScript.Net.Core.UnitTests.Framework.DatapoolFactoryTests' is not 'GrinderScript.Net.Core.UnitTests.Framework.DatapoolFactoryTests+TestValue'"), () => datapoolFactoy.CreateDatapool <TestValue>()); }
public void CreateDatapoolShouldThrowExceptionWhenFactoryTypeNamePropertyIsMissing() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("valueType"))).Returns(typeof(TestValue).FullName); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("factoryType"))).Returns <string>(null); Assert.Throws(Is.InstanceOf <ArgumentException>().With.Message.EqualTo("Missing property 'grinderscript-dotnet.datapool.TestValue.factoryType'"), () => datapoolFactoy.CreateDatapool <TestValue>()); }
public void CreateDatapoolShouldThrowExceptionWhenFactoryTypeNamePropertyIsNotImplementingInterface() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("valueType"))).Returns(typeof(TestValue).FullName); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("factoryType"))).Returns(typeof(DefaultDatapoolMetadata <>).FullName); Assert.Throws(Is.InstanceOf <ArgumentException>().With.Message.Contains("Type 'GrinderScript.Net.Core.DefaultDatapoolMetadata`1' is not 'GrinderScript.Net.Core.IDatapoolValuesFactory`1[[GrinderScript.Net.Core.UnitTests.Framework.DatapoolFactoryTests+TestValue"), () => datapoolFactoy.CreateDatapool <TestValue>()); }
public void LastElementPropertyShouldBeNotBeLessThanFirstElement() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("lastElement"), "100")).Returns("0"); Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Property 'grinderscript-dotnet.datapoolFactory.lastElement' can not be < 'grinderscript-dotnet.datapoolFactory.firstElement' (1), but was 0"), () => datapoolFactoy.CreateMissingDatapoolsFromProperties()); }
public void CtorShouldSetDatapoolManager() { var datapoolFactory = new DatapoolFactory(grinderContextMock.Object, datapoolManagerMock.Object); Assert.That(datapoolFactory.DatapoolManager, Is.SameAs(datapoolManagerMock.Object)); }
public void CreateDatapoolShouldUseSeedPropertyValue() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("seed"), It.IsAny <string>())).Returns("13"); SetupValueFactoryMockAndCreateTestDatapool(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.Is <IDatapoolMetatdata <TestValue> >(m => m.Seed == 13))); }
public void CreateDatapoolShouldUseCircularPropertyValue() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("circular"), bool.TrueString)).Returns(bool.FalseString); SetupValueFactoryMockAndCreateTestDatapool(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.Is <IDatapoolMetatdata <TestValue> >(m => !m.IsCircular))); }
public void CreateDatapoolShouldUseDistributionModePropertyValue() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValue>("distributionMode"), DatapoolThreadDistributionMode.ThreadShared.ToString())).Returns(DatapoolThreadDistributionMode.ThreadComplete.ToString()); SetupValueFactoryMockAndCreateTestDatapool(); datapoolManagerMock.Verify(dm => dm.BuildDatapool(It.Is <IDatapoolMetatdata <TestValue> >(m => m.DistributionMode == DatapoolThreadDistributionMode.ThreadComplete))); }
public void CtorShouldSetTypeHelper() { var datapoolFactory = new DatapoolFactory(grinderContextMock.Object, datapoolManagerMock.Object); Assert.That(datapoolFactory.TypeHelper, Is.Not.Null); }
public void CreateMissingDatapoolsFromPropertiesShouldUseDefaultLastElementWhenPropertyIsMissing() { datapoolFactoy.CreateMissingDatapoolsFromProperties(); grinderContextMock.Verify(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("1"))); }
public void FirstElementPropertyShouldBeGreaterThanZero() { grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetFactoryPropertyKey("firstElement"), "1")).Returns("0"); Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Property 'grinderscript-dotnet.datapoolFactory.firstElement' should be > 0, but was 0"), () => datapoolFactoy.CreateMissingDatapoolsFromProperties()); }
public void SetUp() { factory = new CsvDatapoolValuesFactory <TestValues>(); grinderContextMock = new Mock <IGrinderContext>(); grinderContextMock.Setup(c => c.GetProperty(DatapoolFactory.GetPropertyKey <TestValues>("csvFile"), "TestValues.csv")).Returns("TestValues.csv"); }