Ejemplo n.º 1
0
 public static IfFilterExpression IfPropertyImplements(
     this ConventionExpression conventionExpression,
     Type typeImplemented)
 {
     return(conventionExpression.IfProperty(p =>
                                            p.PropertyType.Implements(typeImplemented) ||
                                            p.PropertyType.ImplementsGenericOf(typeImplemented)));
 }
Ejemplo n.º 2
0
 public static IfFilterExpression IfPropertyIs <TType>(
     this ConventionExpression conventionExpression,
     Expression <Func <TType, object> > expression) where TType : class
 {
     return(conventionExpression.IfProperty(p =>
                                            p.DeclaringType == typeof(TType) &&
                                            p.Name == expression.ToAccessor().Name));
 }
Ejemplo n.º 3
0
        public static Fixture AddConvention(this Fixture fixture, Faker faker, Action <ConventionExpression> convention)
        {
            var conventionExpression = new ConventionExpression(faker);

            convention(conventionExpression);

            fixture.AddOrInsertMiruSpecimen(conventionExpression);

            return(fixture);
        }
Ejemplo n.º 4
0
        private static void AddOrInsertMiruSpecimen(this Fixture fixture, ConventionExpression conventionExpression)
        {
            var existentSpecimenIndex = fixture.Customizations.FindIndex(x => x is MiruConventionSpecimenBuilder);

            var specimen = new MiruConventionSpecimenBuilder(conventionExpression);

            if (existentSpecimenIndex < 0)
            {
                fixture.Customizations.Add(specimen);
            }
            else
            {
                fixture.Customizations.Insert(existentSpecimenIndex, specimen);
            }
        }
Ejemplo n.º 5
0
 public static IfFilterExpression IfPropertyNameIs(
     this ConventionExpression conventionExpression, string propertyName)
 {
     return(conventionExpression.IfProperty(p => p.Name == propertyName));
 }
Ejemplo n.º 6
0
 public static IfFilterExpression IfClassImplements <TType>(this ConventionExpression conventionExpression)
 {
     return(conventionExpression.IfClass(t => t.Implements <TType>()));
 }
Ejemplo n.º 7
0
 public static IfFilterExpression IfClassIs <TType>(this ConventionExpression conventionExpression)
 {
     return(conventionExpression.IfClass(t => t == typeof(TType)));
 }
Ejemplo n.º 8
0
 public static IfFilterExpression IfPropertyImplementsEnumerableOf <TType>(
     this ConventionExpression conventionExpression)
 {
     return(conventionExpression.IfProperty(p => p.PropertyType.ImplementsEnumerableOf <TType>()));
 }
Ejemplo n.º 9
0
 public static IfFilterExpression IfPropertyTypeIs <TType>(this ConventionExpression conventionExpression)
 {
     return(conventionExpression.IfProperty(p => p.PropertyType == typeof(TType)));
 }
Ejemplo n.º 10
0
 public static IfFilterExpression IfPropertyNameEnds(
     this ConventionExpression conventionExpression, string propertyNameEnd)
 {
     return(conventionExpression.IfProperty(p => p.Name.EndsWith(propertyNameEnd)));
 }
Ejemplo n.º 11
0
 public MiruConventionSpecimenBuilder(ConventionExpression convention)
 {
     Convention = convention;
 }
Ejemplo n.º 12
0
 public UseExpression(Func <object> use, ConventionExpression conventionExpression)
 {
     _use = use;
     _conventionExpression = conventionExpression;
 }