Пример #1
0
        private void GetAllDomains(IDomainCollection domains, ParameterInfo parameter, Type t)
        {
            foreach (MethodInfo factoryMethod in TypeHelper.GetAttributedMethods(t, typeof(FactoryAttribute)))
            {
                if (factoryMethod.GetParameters().Length > 0)
                {
                    continue;
                }
                Type returnType = factoryMethod.ReturnType;

                // check single object return
                if (parameter.ParameterType.IsAssignableFrom(returnType))
                {
                    object  result = this.InvokeMethod(t, factoryMethod);
                    IDomain domain = Domains.ToDomain(result);
                    domain.Name = factoryMethod.Name;
                    domains.Add(domain);
                    continue;
                }

                // check array
                if (returnType.HasElementType)
                {
                    Type elementType = returnType.GetElementType();
                    if (parameter.ParameterType == elementType)
                    {
                        object  result = this.InvokeMethod(t, factoryMethod);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }

                // check factory type
                FactoryAttribute factoryAttribute = TypeHelper.TryGetFirstCustomAttribute(factoryMethod, typeof(FactoryAttribute)) as FactoryAttribute;
                if (factoryAttribute != null)
                {
                    Type factoredType = factoryAttribute.FactoredType;
                    if (parameter.ParameterType == factoredType)
                    {
                        object  result = this.InvokeMethod(t, factoryMethod);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }
            }
        }
        /// <summary>
        /// Gets the set of values (the collection of domains) for the parameter.
        /// </summary>
        /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
        /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
        /// <param name="fixture">The test fixture.</param>
        /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
        /// domain generation</remarks>
        public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture)
        {
            ArrayList types = new ArrayList();

            foreach (Type type in typeFromAssembly.Assembly.GetExportedTypes())
            {
                if (type.IsAbstract || type.IsInterface || !type.IsClass)
                {
                    continue;
                }

                if (!parameter.ParameterType.IsAssignableFrom(type))
                {
                    continue;
                }

                // create instance
                Object instance = TypeHelper.CreateInstance(type);
                types.Add(instance);
            }

            CollectionDomain domain = new CollectionDomain(types);

            domain.Name = typeFromAssembly.Assembly.GetName().Name;
            domains.Add(domain);
        }
Пример #3
0
        /// <summary>
        /// Gets the set of values (the collection of domains) for the parameter.
        /// </summary>
        /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
        /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
        /// <param name="fixture">The test fixture.</param>
        /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
        /// domain generation</remarks>
        public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture)
        {
            bool      isString = parameter.ParameterType.IsAssignableFrom(typeof(string));
            ArrayList data     = new ArrayList();

            foreach (string memberName in this.Values.Split(';'))
            {
                object cresult = null;
                if (isString)
                {
                    cresult = memberName.ToString();
                }
                else
                {
                    cresult = Convert.ChangeType(memberName, parameter.ParameterType);
                }
                data.Add(cresult);
            }
            if (data.Count == 0)
            {
                return;
            }

            CollectionDomain domain = new CollectionDomain(data);

            domains.Add(domain);
        }
Пример #4
0
 /// <summary>
 /// Gets the set of values (the collection of domains) for the parameter.
 /// </summary>
 /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
 /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
 /// <param name="fixture">The test fixture.</param>
 /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
 /// domain generation</remarks>
 public override void GetDomains(
     IDomainCollection domains,
     ParameterInfo parameter,
     object fixture) {
     ArrayDomain domain = new ArrayDomain(Enum.GetValues(this.EnumType));
     domains.Add(domain);
 }
Пример #5
0
        /// <summary>
        /// Gets the set of values (the collection of domains) for the parameter.
        /// </summary>
        /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
        /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
        /// <param name="fixture">The test fixture.</param>
        /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
        /// domain generation</remarks>
        public override void GetDomains(
            IDomainCollection domains,
            ParameterInfo parameter,
            object fixture)
        {
            ArrayDomain domain = new ArrayDomain(Enum.GetValues(this.EnumType));

            domains.Add(domain);
        }
        /// <summary>
        /// Gets the set of values (the collection of domains) for the parameter.
        /// </summary>
        /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
        /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
        /// <param name="fixture">The test fixture.</param>
        /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
        /// domain generation</remarks>
        public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture) {
            ArrayList types = new ArrayList();
            foreach (Type type in typeFromAssembly.Assembly.GetExportedTypes()) {
                if (type.IsAbstract || type.IsInterface || !type.IsClass)
                    continue;

                if (!parameter.ParameterType.IsAssignableFrom(type))
                    continue;

                // create instance
                Object instance = TypeHelper.CreateInstance(type);
                types.Add(instance);
            }

            CollectionDomain domain = new CollectionDomain(types);
            domain.Name = typeFromAssembly.Assembly.GetName().Name;
            domains.Add(domain);
        }
Пример #7
0
        private void GetNamedDomains(IDomainCollection domains, ParameterInfo parameter, Type t)
        {
            foreach (string memberName in this.MemberNames.Split(';'))
            {
                MethodInfo domainMethod = t.GetMethod(memberName, Type.EmptyTypes);
                if (domainMethod == null)
                {
                    Assert.Fail("Could not find domain method {0} for parameter {1}",
                                memberName, parameter.Name);
                }

                object result = this.InvokeMethod(t, domainMethod);

                IDomain domain = Domains.ToDomain(result);
                domain.Name = domainMethod.Name;
                domains.Add(domain);
            }
        }
        public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture)
        {
            bool isString = parameter.ParameterType.IsAssignableFrom(typeof(string));
            ArrayList data = new ArrayList();
            foreach (string memberName in this.Values.Split(';'))
            {
                object cresult = null;
                if (isString)
                    cresult = memberName.ToString();
                else
                    cresult = Convert.ChangeType(memberName, parameter.ParameterType);
                data.Add(cresult);
            }
            if (data.Count == 0)
                return;

            CollectionDomain domain = new CollectionDomain(data);
            domains.Add(domain);
        }
        private void GetNamedDomains(IDomainCollection domains, ParameterInfo parameter, Type t)
        {
            foreach (string memberName in this.MemberNames.Split(';'))
            {
                MethodInfo domainMethod = t.GetMethod(memberName, Type.EmptyTypes);
                if (domainMethod == null)
                    Assert.Fail("Could not find domain method {0} for parameter {1}",
                        memberName, parameter.Name);

                object result = this.InvokeMethod(t, domainMethod);

                IDomain domain = Domains.ToDomain(result);
                domain.Name = domainMethod.Name;
                domains.Add(domain);
            }
        }
        private void GetAllDomains(IDomainCollection domains, ParameterInfo parameter, Type t)
        {
            foreach (MethodInfo factoryMethod in TypeHelper.GetAttributedMethods(t, typeof(FactoryAttribute)))
            {
                if (factoryMethod.GetParameters().Length > 0)
                    continue;
                Type returnType = factoryMethod.ReturnType;

                // check single object return
                if (parameter.ParameterType.IsAssignableFrom(returnType))
                {
                    object result = this.InvokeMethod(t, factoryMethod);
                    IDomain domain = Domains.ToDomain(result);
                    domain.Name = factoryMethod.Name;
                    domains.Add(domain);
                    continue;
                }

                // check array
                if (returnType.HasElementType)
                {
                    Type elementType = returnType.GetElementType();
                    if (parameter.ParameterType == elementType)
                    {
                        object result = this.InvokeMethod(t, factoryMethod);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }

                // check factory type
                FactoryAttribute factoryAttribute = TypeHelper.TryGetFirstCustomAttribute(factoryMethod, typeof(FactoryAttribute)) as FactoryAttribute;
                if (factoryAttribute != null)
                {
                    Type factoredType = factoryAttribute.FactoredType;
                    if (parameter.ParameterType == factoredType)
                    {
                        object result = this.InvokeMethod(t, factoryMethod);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }
            }
        }
Пример #11
0
 /// <summary>
 /// Gets the set of values (the collection of domains) for the parameter.
 /// </summary>
 /// <param name="domains">The <see cref="IDomainCollection"/> the values generated by the source of data</param>
 /// <param name="parameter"><see cref="ParameterInfo"/> for the parameter that wants the values.</param>
 /// <param name="fixture">The test fixture.</param>
 /// <remarks>See <a href="http://blog.dotnetwiki.org/CombinatorialTestingWithTestFu1.aspx">here</a> for more on
 /// domain generation</remarks>
 public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture)
 {
     domains.Add(domain);
 }
 public override void GetDomains(IDomainCollection domains, ParameterInfo parameter, object fixture)
 {
     domains.Add(domain);
 }