Exemplo n.º 1
0
        protected when_running_specs Run(params Type[] types)
        {
            //if (types.Count() == 1) tags = types.First().Name;

            this.types = types;

            builder = new ContextBuilder(new SpecFinder(types), new Tags().Parse(tags), new DefaultConventions());

            runner = new ContextRunner(builder, formatter, failFast);

            contextCollection = builder.Contexts();

            contextCollection.Build();

            classContext = contextCollection
                .AllContexts()
                .Where(c => c is ClassContext)
                .Cast<ClassContext>()
                .FirstOrDefault(c => types.Contains(c.type));

            methodContext = contextCollection.AllContexts().FirstOrDefault(c => c is MethodContext);

            runner.Run(contextCollection);

            return this;
        }
Exemplo n.º 2
0
        protected void Run(Type type)
        {
            classContext = new ClassContext(type, convention);

            var method = type.Methods().First().Name;

            Run(type, method);
        }
Exemplo n.º 3
0
        public void setup()
        {
            parentContext = new ClassContext(typeof(parent_act));

            childContext = new ClassContext(typeof(child_act));

            parentContext.AddContext(childContext);

            instance = new child_act();

            parentContext.Build();
        }
Exemplo n.º 4
0
        public static Context RootContext(this Type type, Context childContext=null)
        {
            if (type.BaseType == typeof(nspec))
            {
                var context = new ClassContext( type );

                if(childContext!=null) context.AddContext(childContext);

                return context;
            }

            return RootContext(type.BaseType, new ClassContext(type));
        }
Exemplo n.º 5
0
        protected void Run(Type type, string methodName)
        {
            classContext = new ClassContext(type, convention);

            var method = type.Methods().Single(s => s.Name == methodName);

            methodContext = new MethodContext(method);

            classContext.AddContext(methodContext);

            classContext.Build();

            classContext.Run();
        }
Exemplo n.º 6
0
        public ContextCollection Contexts()
        {
            contexts.Clear();

            conventions.Initialize();

            var specClasses = finder.SpecClasses();

            var container = new ClassContext(typeof(nspec), conventions, tagsFilter);

            Build(container, specClasses);

            contexts.AddRange(container.Contexts);

            return contexts;
        }
Exemplo n.º 7
0
        public ClassContext CreateClassContext(Type type)
        {
            var tagAttributes = ((TagAttribute[])type.GetCustomAttributes(typeof(TagAttribute), false)).ToList();

            tagAttributes.Add(new TagAttribute(type.Name));

            type.GetAbstractBaseClassChainWithClass()
                .Where(s => s != type)
                .Each(s => tagAttributes.Add(new TagAttribute(s.Name)));

            var tags = TagStringFor(tagAttributes);

            var context = new ClassContext(type, conventions, tagsFilter, tags);

            return context;
        }
Exemplo n.º 8
0
        public ClassContext CreateClassContext(Type type)
        {
            var tagAttributes = ((TagAttribute[])type.GetTypeInfo().GetCustomAttributes(typeof(TagAttribute), false)).ToList();

            tagAttributes.Add(new TagAttribute(type.Name));

            type.GetAbstractBaseClassChainWithClass()
            .Where(s => s != type)
            .Do(s => tagAttributes.Add(new TagAttribute(s.Name)));

            var tags = TagStringFor(tagAttributes);

            var context = new ClassContext(type, conventions, tagsFilter, tags);

            return(context);
        }
Exemplo n.º 9
0
        public ContextCollection Contexts()
        {
            contexts.Clear();

            conventions.Initialize();

            var specClasses = finder.SpecClasses().OrderBy(type => type.Name);

            var container = new ClassContext(typeof(nspec), conventions, tagsFilter);

            Build(container, specClasses);

            contexts.AddRange(container.Contexts);

            return(contexts);
        }
Exemplo n.º 10
0
        protected void Run(Type type)
        {
            var finder = new SpecFinder(new[] { type });

            var builder = new ContextBuilder(finder, new DefaultConventions());

            var contexts = builder.Contexts();

            contexts.Build();

            contexts.Run();

            classContext = contexts
                .AllContexts()
                .Select(c => c as ClassContext)
                .First(c => c.type == type);

            methodContext = contexts.AllContexts().First(c => c is MethodContext);
        }
Exemplo n.º 11
0
        protected when_running_specs Init(Type[] types, string tags = null, bool failFast = false)
        {
            this.types = types;

            builder = new ContextBuilder(new SpecFinder(types), new Tags().Parse(tags), new DefaultConventions());

            runner = new ContextRunner(builder, formatter, failFast);

            contextCollection = builder.Contexts();

            contextCollection.Build();

            classContext = contextCollection
                .AllContexts()
                .Where(c => c is ClassContext)
                .Cast<ClassContext>()
                .FirstOrDefault(c => types.Contains(c.type));

            methodContext = contextCollection.AllContexts().FirstOrDefault(c => c is MethodContext);

            return this;
        }
Exemplo n.º 12
0
        public void setup()
        {
            conventions = new DefaultConventions();

            conventions.Initialize();

            parentContext = new ClassContext(typeof(parent_before), conventions);

            childContext = new ClassContext(typeof(child_before), conventions);

            parentContext.AddContext(childContext);
        }
Exemplo n.º 13
0
        public ClassContext CreateClassContext(Type type)
        {
            var tagAttributes = ((TagAttribute[])type.GetCustomAttributes(typeof(TagAttribute), false)).ToList();

            tagAttributes.Add(new TagAttribute(type.Name));

            var tags = TagStringFor(tagAttributes);

            var context = new ClassContext(type, conventions, tagsFilter, tags);

            return context;
        }
Exemplo n.º 14
0
        private ClassContext CreateClassContext(Type type, Conventions conventions)
        {
            var context = new ClassContext(type, conventions);

            BuildMethodContexts(context, type);

            BuildMethodLevelExamples(context, type);

            return context;
        }