private IEnumerable <IConvention> ProvideNamedConventions(IFixtureConfiguration configuration) { var dataGenerator = configuration.Locate <IRandomDataGeneratorService>(); var helper = configuration.Locate <IConstraintHelper>(); yield return(new StringNamedConvention(dataGenerator, helper)); }
private IEnumerable <IConvention> ProvideDefaultConventions(IFixtureConfiguration configuration) { var dataGenerator = configuration.Locate <IRandomDataGeneratorService>(); var helper = configuration.Locate <IConstraintHelper>(); yield return(new BoolConvention(dataGenerator)); yield return(new ByteConvention(dataGenerator, helper)); yield return(new CharConvention(dataGenerator, helper)); yield return(new DateTimeConvention(dataGenerator, helper)); yield return(new DecimalConvention(dataGenerator, helper)); yield return(new DelegateConvention(helper)); yield return(new DoubleConvention(dataGenerator, helper)); yield return(new EnumConvention(dataGenerator, helper)); yield return(new IntConvention(dataGenerator, helper)); yield return(new LongConvention(dataGenerator, helper)); yield return(new SByteConvention(dataGenerator, helper)); yield return(new ShortConvention(dataGenerator, helper)); yield return(new StringConvention(dataGenerator, helper)); yield return(new TimeSpanConvention(dataGenerator, helper)); yield return(new TypeConvention(dataGenerator)); yield return(new UIntConvention(dataGenerator, helper)); yield return(new ULongConvention(dataGenerator, helper)); yield return(new UriConvention(helper)); yield return(new UShortConvention(dataGenerator, helper)); yield return(new ComplexConvention(configuration)); yield return(new ArrayConvention()); yield return(new DictionaryConvention()); yield return(new ListConvention(configuration)); yield return(new ReadOnlyCollectionConvention()); yield return(new IComparerConvention()); yield return(new IEqualityComparerConvention()); yield return(new NullableConvention()); }
/// <summary> /// Default constructor /// </summary> /// <param name="configuration"></param> public ComplexConvention(IFixtureConfiguration configuration) { _configuration = configuration; _typeCreator = configuration.Locate <ITypeCreator>(); _typePopulator = configuration.Locate <ITypePopulator>(); _circularReferenceHandler = configuration.Locate <ICircularReferenceHandler>(); _modelService = configuration.Locate <IModelService>(); }
private void Initalize() { Add(_returnConventions); Add(_typedConventions); var conventionProvider = _configuration.Locate <IConventionProvider>(); foreach (var providedConvention in conventionProvider.ProvideConventions(Configuration)) { Add(providedConvention); } // using specific type incase it's inheritance Return <Fixture>(this); Return(_configuration.Locate <IRandomDataGeneratorService>()); }
/// <summary> /// Default constructor /// </summary> /// <param name="configuration"></param> public Fixture(IFixtureConfiguration configuration = null) { _configuration = configuration ?? new DefaultFixtureConfiguration(); _conventions = _configuration.Locate <IConventionList>(); _behavior = new BehaviorCollection(); _returnConventions = new TypedConventions(Configuration, ConventionPriority.First); _typedConventions = new TypedConventions(Configuration); Initalize(); }
/// <summary> /// Add typed convention /// </summary> /// <param name="typedConvention">convention</param> public void AddConvention(ITypedConvention typedConvention) { if (_typedConventions == null) { _typedConventions = new Dictionary <Type, IConventionList>(); } IConventionList conventionList; foreach (var supportedType in typedConvention.SupportedTypes) { if (!_typedConventions.TryGetValue(supportedType, out conventionList)) { conventionList = _configuration.Locate <IConventionList>(); _typedConventions[supportedType] = conventionList; } conventionList.AddConvention(typedConvention); } }