/// <summary> /// Given 2 strings, filters the left-hand string and checks whether the filtered output matches that of the right-hand string. /// </summary> /// <param name="filter">The source filter to apply</param> /// <param name="defines">The preprocessor definitions which are to be used by the source filter</param> /// <param name="lhs">The left-hand string whose value will be filtered</param> /// <param name="rhs">The right-hand string whose value is used to compare the filtered result</param> protected void FilterAndCompare(ISourceFilter filter, Defines defines, string lhs, string rhs) { var cppSourceFile = new CppSourceFile(){SourceCode = lhs}; filter.Filter(cppSourceFile, defines); Assert.AreEqual(cppSourceFile.SourceCode, rhs); }
/// <summary> /// Given 2 embedded resources locations, filters the left-hand resource and checks whether the filtered output matches that of the right-hand resource. /// </summary> /// <param name="filter">The source filter to apply</param> /// <param name="defines">The preprocessor definitions which are to be used by the source filter</param> /// <param name="lhsEmbeddedResource">The left-hand embedded resource fully qualified location whose content will be filtered</param> /// <param name="rhsEmbeddedResource">The right-hand embedded resource fully qualified location whose content is used to compare the filtered result</param> protected void FilterAndCompareResources(ISourceFilter filter, Defines defines, string lhsEmbeddedResource, string rhsEmbeddedResource) { FilterAndCompare( filter, defines, TestHelper.ReadEmbeddedResource(lhsEmbeddedResource), TestHelper.ReadEmbeddedResource(rhsEmbeddedResource) ); }
/// <summary> /// Given 2 embedded resources locations, filters the left-hand resource and checks whether the filtered output matches that of the right-hand resource. /// </summary> /// <param name="filter">The source filter to apply</param> /// <param name="defines">The preprocessor definitions which are to be used by the source filter</param> /// <param name="lhsEmbeddedResource">The left-hand embedded resource fully qualified location whose content will be filtered</param> /// <param name="rhsEmbeddedResource">The right-hand embedded resource fully qualified location whose content is used to compare the filtered result</param> protected void FilterAndCompareResources(ISourceFilter filter, Defines defines, string lhsEmbeddedResource, string rhsEmbeddedResource) { FilterAndCompare( filter, defines, TestHelper.ReadEmbeddedResource(lhsEmbeddedResource), TestHelper.ReadEmbeddedResource(rhsEmbeddedResource) ); }
/// <summary> /// Given 2 strings, filters the left-hand string and checks whether the filtered output matches that of the right-hand string. /// </summary> /// <param name="filter">The source filter to apply</param> /// <param name="defines">The preprocessor definitions which are to be used by the source filter</param> /// <param name="lhs">The left-hand string whose value will be filtered</param> /// <param name="rhs">The right-hand string whose value is used to compare the filtered result</param> protected void FilterAndCompare(ISourceFilter filter, Defines defines, string lhs, string rhs) { var cppSourceFile = new CppSourceFile() { SourceCode = lhs }; filter.Filter(cppSourceFile, defines); Assert.AreEqual(cppSourceFile.SourceCode, rhs); }
/// <summary> /// Applies the discovery process over the provided DummySolution /// </summary> /// <param name="solution">The dummy solution on which to apply test discovery</param> /// <returns>The list of tests which were discovered from the dummy solution</returns> private IList<TestCase> DiscoverTests(DummySolution solution) { DefaultTestCaseDiscoverySink discoverySink = new DefaultTestCaseDiscoverySink(); ISourceFilter[] filters = new ISourceFilter[] { new QuotedStringsFilter(), new MultilineCommentFilter(), new SingleLineCommentFilter(), new ConditionalInclusionsFilter(new ExpressionEvaluation()) }; SourceCodeDiscoverer discoverer = new SourceCodeDiscoverer(solution.Provider); discoverer.DiscoverTests(new []{solution.Source}, new DefaultTestContext(true), new ConsoleMessageLogger(), discoverySink); return discoverySink.Tests.ToList(); }
/// <summary> /// Applies the discovery process over the provided DummySolution /// </summary> /// <param name="solution">The dummy solution on which to apply test discovery</param> /// <returns>The list of tests which were discovered from the dummy solution</returns> private IList <TestCase> DiscoverTests(DummySolution solution) { DefaultTestCaseDiscoverySink discoverySink = new DefaultTestCaseDiscoverySink(); ISourceFilter[] filters = new ISourceFilter[] { new QuotedStringsFilter(), new MultilineCommentFilter(), new SingleLineCommentFilter(), new ConditionalInclusionsFilter(new ExpressionEvaluation()) }; SourceCodeDiscoverer discoverer = new SourceCodeDiscoverer(solution.Provider); discoverer.DiscoverTests(new [] { solution.Source }, new DefaultTestContext(true), discoverySink); return(discoverySink.Tests.ToList()); }
/// <summary> /// 构建查询描述器 /// </summary> /// <param name="query"></param> /// <param name="sort"></param> /// <param name="fields"></param> /// <param name="aggs"></param> /// <param name="from"></param> /// <param name="size"></param> /// <returns></returns> public SearchDescriptor <T> BuildSearchDescriptor(QueryContainer query, SortDescriptor <T> sort, ISourceFilter fields, IAggregationContainer aggs, int from = 0, int size = 10) { var searchdesc = new SearchDescriptor <T>() .Index(EsIndex) .Type(EsType) .From(from) .Size(size); if (query != null) { searchdesc = searchdesc.Query(q => query); } if (sort != null) { searchdesc = searchdesc.Sort(s => sort); } if (fields != null) { searchdesc = searchdesc.Source(s => fields); } if (aggs != null) { searchdesc = searchdesc.Aggregations(a => aggs); } return(searchdesc); }
/// <summary> /// Applies the discovery process over the provided DummySolution /// </summary> /// <param name="solution">The dummy solution on which to apply test discovery</param> /// <returns>The list of tests which were discovered from the dummy solution</returns> private IList<TestCase> DiscoverTests(DummySolution solution) { DefaultTestCaseDiscoverySink discoverySink = new DefaultTestCaseDiscoverySink(); ISourceFilter[] filters = new ISourceFilter[] { new QuotedStringsFilter(), new MultilineCommentFilter(), new SingleLineCommentFilter(), new ConditionalInclusionsFilter(new ExpressionEvaluation()) }; BoostTestDiscovererInternal discoverer = new BoostTestDiscovererInternal(solution.Provider, filters); IDictionary<string, ProjectInfo> solutionInfo = discoverer.PrepareTestCaseData(new string[] { solution.Source }); discoverer.GetBoostTests(solutionInfo, discoverySink); return discoverySink.Tests.ToList(); }
/// <summary> /// Control how the document's source is loaded /// </summary> public MultiGetOperationDescriptor <T> Source(ISourceFilter source) { Self.Source = source; return(this); }
/// <summary> /// Constructor /// </summary> /// <param name="provider">The Visual Studio instance provider</param> /// <param name="newSourceFilters">source filters object that will be used to filter inactive code</param> public BoostTestDiscovererInternal(IVisualStudioInstanceProvider provider, ISourceFilter[] newSourceFilters) { this.VSProvider = provider; this._sourceFilters = newSourceFilters; }