public void Test_RegisterCustomBOTestFactory_ForAPropDef_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- var registry= new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf<ValidValueGeneratorString>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorIncrementalInt)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorIncrementalInt>(validValueGenerator); }
public void Test_RegisterTwice_ForAPropDef_ShouldStoreSecond() { //---------------Set up test pack------------------- var registry= new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); registry.Register(stringPropDef, typeof(ValidValueGeneratorEnum)); //---------------Assert Precondition---------------- Assert.IsInstanceOf<ValidValueGeneratorEnum>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator); }
public void Test_RegisterCustomBOTestFactory_ForAPropDef_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf <ValidValueGeneratorString>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorIncrementalInt)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorIncrementalInt>(validValueGenerator); }
public void Test_RegisterCustomGenForTypeAndForPropDef_ShouldReturnPropDefRegistration() { //---------------Set up test pack------------------- var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); registry.Register(stringPropDef, typeof(ValidValueGeneratorInt)); //---------------Assert Precondition---------------- Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator); }
public void Test_RegisterTwice_ForAPropDef_ShouldStoreSecond() { //---------------Set up test pack------------------- var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); registry.Register(stringPropDef, typeof(ValidValueGeneratorEnum)); //---------------Assert Precondition---------------- Assert.IsInstanceOf <ValidValueGeneratorEnum>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator); }
public void Test_Resolve_WhenNoPropDefRegistered_ShouldReturnForType() { //---------------Set up test pack------------------- var registry = new BOPropValueGeneratorRegistry(); var stringPropDef1 = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf <ValidValueGeneratorString>(registry.Resolve(stringPropDef1)); //---------------Execute Test ---------------------- ValidValueGeneratorRegistry.Instance.Register <string, ValidValueGeneratorInt>(); ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorInt>(validValueGenerator1); }
public void Test_ResolveForDifPropDefShouldReturnDefaultValidValGen() { //---------------Set up test pack------------------- var registry = new BOPropValueGeneratorRegistry(); ValidValueGeneratorRegistry.Instance.Register <string, ValidValueGeneratorInt>(); var stringPropDef1 = GetStringPropDef(); var stringPropDef2 = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef1)); Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef2)); //---------------Execute Test ---------------------- registry.Register(stringPropDef1, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1); ValidValueGenerator validValueGenerator2 = registry.Resolve(stringPropDef2); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator1); Assert.IsInstanceOf <ValidValueGeneratorInt>(validValueGenerator2); }
public void Test_RegisterCustomBOTestFactory_AdditionalParameter_PassedToGenerator() { //---------------Set up test pack------------------- var randomParameter = RandomValueGen.GetRandomString(); var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorTextFile), randomParameter); var validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf <ValidValueGeneratorTextFile>(validValueGenerator); Assert.AreEqual(randomParameter, ((ValidValueGeneratorTextFile)validValueGenerator).FileName); }
public void Test_RegisterCustomBOTestFactory_AdditionalParameter_ExceptionIfSuitableConstructorNotFound() { //---------------Set up test pack------------------- var randomParameter = RandomValueGen.GetRandomString(); var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(GeneratorStub), randomParameter); try { registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.Fail("Expected to throw an ArgumentException"); } catch (ArgumentException ex) { StringAssert.Contains("An extra parameter was provided for a valid value generator type (GeneratorStub), but no suitable constructor was found with a second parameter.", ex.Message); } }
public void Test_ResolveForDifPropDefShouldReturnDefaultValidValGen() { //---------------Set up test pack------------------- var registry= new BOPropValueGeneratorRegistry(); ValidValueGeneratorRegistry.Instance.Register<string, ValidValueGeneratorInt>(); var stringPropDef1 = GetStringPropDef(); var stringPropDef2 = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef1)); Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef2)); //---------------Execute Test ---------------------- registry.Register(stringPropDef1, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1); ValidValueGenerator validValueGenerator2 = registry.Resolve(stringPropDef2); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator1); Assert.IsInstanceOf<ValidValueGeneratorInt>(validValueGenerator2); }
public void Test_RegisterCustomGenForTypeAndForPropDef_ShouldReturnPropDefRegistration() { //---------------Set up test pack------------------- var registry= new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); registry.Register(stringPropDef, typeof(ValidValueGeneratorInt)); //---------------Assert Precondition---------------- Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef)); //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal)); ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator); }
public void Test_RegisterCustomBOTestFactory_AdditionalParameter_PassedToGenerator() { //---------------Set up test pack------------------- var randomParameter = RandomValueGen.GetRandomString(); var registry = new BOPropValueGeneratorRegistry(); var stringPropDef = GetStringPropDef(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- registry.Register(stringPropDef, typeof(ValidValueGeneratorTextFile), randomParameter); var validValueGenerator = registry.Resolve(stringPropDef); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorTextFile>(validValueGenerator); Assert.AreEqual(randomParameter, ((ValidValueGeneratorTextFile)validValueGenerator).FileName); }
public void Test_Resolve_WhenNoPropDefRegistered_ShouldReturnForType() { //---------------Set up test pack------------------- var registry= new BOPropValueGeneratorRegistry(); var stringPropDef1 = GetStringPropDef(); //---------------Assert Precondition---------------- Assert.IsInstanceOf<ValidValueGeneratorString>(registry.Resolve(stringPropDef1)); //---------------Execute Test ---------------------- ValidValueGeneratorRegistry.Instance.Register<string, ValidValueGeneratorInt>(); ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1); //---------------Test Result ----------------------- Assert.IsInstanceOf<ValidValueGeneratorInt>(validValueGenerator1); }