public TestCaseDTO[] DiscoverTests() { var conv = new DefaultConventions().Initialize(); var finder = new SpecFinder(SandboxedAssembly.GetTypes(), ""); var cb = new ContextBuilder(finder, new Tags()); var dia = new DiaSession(SandboxedAssembly.Location); var examples = cb.Contexts() .Build() .AllContexts() .SelectMany(context => context.Examples); var result = from example in examples let method = GetAction(example) let location = dia.GetNavigationData(method.DeclaringType.FullName, method.Name) ?? new DiaNavigationData(null, 0, 0) select new TestCaseDTO { Name = example.FullName(), FileName = location.FileName, LineNumber = location.MinLineNumber, Traits = example.Tags.ToArray() }; return(result.ToArray()); }
public TestCaseDTO[] DiscoverTests() { var conv = new DefaultConventions().Initialize(); var finder = new SpecFinder(SandboxedAssembly.GetTypes(), ""); var cb = new ContextBuilder(finder, new Tags()); var dia = new DiaSession(SandboxedAssembly.Location); var examples = cb.Contexts() .Build() .AllContexts() .SelectMany(context => context.Examples); var result = from example in examples let method = GetAction(example) let location = dia.GetNavigationData(method.DeclaringType.FullName, method.Name) ?? new DiaNavigationData(null, 0, 0) select new TestCaseDTO { Name = example.FullName(), FileName = location.FileName, LineNumber = location.MinLineNumber, Traits = example.Tags.ToArray() }; return result.ToArray(); }
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); }
public void setup_base() { finder = MockRepository.GenerateMock <ISpecFinder>(); typesForFinder = new List <Type>(); finder.Stub(f => f.SpecClasses()).IgnoreArguments().Return(typesForFinder); DefaultConventions conventions = new DefaultConventions(); conventions.Initialize(); builder = new ContextBuilder(finder, conventions); }
public void setup() { var finder = MockRepository.GenerateMock <ISpecFinder>(); DefaultConventions defaultConvention = new DefaultConventions(); defaultConvention.Initialize(); var builder = new ContextBuilder(finder, defaultConvention); classContext = new Context("class"); builder.BuildMethodContexts(classContext, typeof(SpecClass)); }
public void Select(string binaryPath, string tagsText) { var reflector = new Reflector(binaryPath); var finder = new SpecFinder(reflector); var conventions = new DefaultConventions(); TagsFilter = new Tags().Parse(tagsText); var builder = new ContextBuilder(finder, TagsFilter, conventions); Contexts = builder.Contexts().Build(); }
public void setup_base() { finder = new Mock <ISpecFinder>(); typesForFinder = new List <Type>(); finder.Setup(f => f.SpecClasses()).Returns(typesForFinder); DefaultConventions conventions = new DefaultConventions(); conventions.Initialize(); builder = new ContextBuilder(finder.Object, conventions); }
public ContextCollection BuildContextCollection(string binaryPath) { var reflector = new Reflector(binaryPath); var finder = new SpecFinder(reflector); var conventions = new DefaultConventions(); var contextBuilder = new ContextBuilder(finder, conventions); var contextCollection = contextBuilder.Contexts(); contextCollection.Build(); return(contextCollection); }
public NSpecResultModel Run(string specName) { var reflector = new Reflector(this._dllFile); var nspecInstance = new nspec(); var conventions = new DefaultConventions(); var finder = new SpecFinder(reflector); var builder = new ContextBuilder(finder, new Tags().Parse(_tags), new DefaultConventions()); var contexts = builder.Contexts().Build(); var context = contexts.AllContexts().FirstOrDefault(t => t.Name == specName); var parentTypeInstance = contexts.AllContexts().FirstOrDefault(t => t is ClassContext); if (context != null && !context.HasAnyExecutedExample() && parentTypeInstance != null) { ILiveFormatter liveFormatter = new SilentLiveFormatter(); if (_formatter is ILiveFormatter) { liveFormatter = _formatter as ILiveFormatter; } var instance = (parentTypeInstance as ClassContext).type.Instance <nspec>(); context.Contexts.Where(t => t is MethodContext).Do(t => (t as MethodContext).Build(instance)); context.Run(_formatter as ILiveFormatter, false, instance); context.AssignExceptions(); if (builder.tagsFilter.HasTagFilters()) { context.TrimSkippedDescendants(); } } var contextCollection = new ContextCollection { context }; _formatter.Write(contextCollection); var serializableContextCollection = new SerializableContextCollection(); BuildResponse(serializableContextCollection, contextCollection); return(new NSpecResultModel { ContextCollection = serializableContextCollection, Output = _formatter.GetFormattedString }); }
public Context(string name = "", string tags = null, bool isPending = false, Conventions conventions = null) { Name = name.Replace("_", " "); Tags = Domain.Tags.ParseTags(tags); this.isPending = isPending; Examples = new List <ExampleBase>(); Contexts = new ContextCollection(); if (conventions == null) { conventions = new DefaultConventions().Initialize(); } runnables = new List <RunnableExample>(); BeforeAllChain = new BeforeAllChain(this, conventions); BeforeChain = new BeforeChain(this, conventions); ActChain = new ActChain(this, conventions); AfterChain = new AfterChain(this, conventions); AfterAllChain = new AfterAllChain(this, conventions); }
public void setup_base() { convention = new DefaultConventions(); convention.Initialize(); }
public string PartialNameConvention(PropertyInfo prop) { return(GetDescriptor(prop.ReflectedType).GetPartialName(prop) ?? DefaultConventions.PartialName(prop)); }
public string LabelConvention(PropertyInfo prop) { return(GetDescriptor(prop.ReflectedType).GetLabel(prop) ?? DefaultConventions.LabelForProperty(prop)); }