/// <summary> /// Initializes a test initially without a parent. /// </summary> /// <param name="name">The name of the test.</param> /// <param name="codeElement">The point of definition of the test, or null if unknown.</param> /// <param name="dataContext">The data context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or <paramref name="dataContext"/> is null.</exception> public PatternTest(string name, ICodeElementInfo codeElement, PatternTestDataContext dataContext) : base(name, codeElement) { if (dataContext == null) throw new ArgumentNullException("dataContext"); this.dataContext = dataContext; testActions = new PatternTestActions(); }
/// <summary> /// Creates a test data context builder. /// </summary> /// <param name="testModelBuilder">The associated test model builder.</param> /// <param name="testDataContext">The underlying test data context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="testModelBuilder"/> /// or <paramref name="testDataContext"/> is null.</exception> public DefaultTestDataContextBuilder(ITestModelBuilder testModelBuilder, PatternTestDataContext testDataContext) { if (testModelBuilder == null) throw new ArgumentNullException("testModelBuilder"); if (testDataContext == null) throw new ArgumentNullException("testDataContext"); this.testModelBuilder = testModelBuilder; this.testDataContext = testDataContext; }
/// <summary> /// Initializes a test initially without a parent. /// </summary> /// <param name="name">The name of the test.</param> /// <param name="codeElement">The point of definition of the test, or null if unknown.</param> /// <param name="dataContext">The data context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or <paramref name="dataContext"/> is null.</exception> public PatternTest(string name, ICodeElementInfo codeElement, PatternTestDataContext dataContext) : base(name, codeElement) { if (dataContext == null) { throw new ArgumentNullException("dataContext"); } this.dataContext = dataContext; testActions = new PatternTestActions(); }
/// <summary> /// Creates a test data context builder. /// </summary> /// <param name="testModelBuilder">The associated test model builder.</param> /// <param name="testDataContext">The underlying test data context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="testModelBuilder"/> /// or <paramref name="testDataContext"/> is null.</exception> public DefaultTestDataContextBuilder(ITestModelBuilder testModelBuilder, PatternTestDataContext testDataContext) { if (testModelBuilder == null) { throw new ArgumentNullException("testModelBuilder"); } if (testDataContext == null) { throw new ArgumentNullException("testDataContext"); } this.testModelBuilder = testModelBuilder; this.testDataContext = testDataContext; }
/// <summary> /// Returns the index that should be used to implicitly bind to the nearest /// anonymous data source that can be found. /// </summary> /// <remarks> /// <para> /// The index is computed as the sum of the <see cref="ImplicitDataBindingIndexOffset" /> of each data /// context traversed to find the data source excluding the data context /// that actually has the data source. /// </para> /// </remarks> /// <returns>The implicit data binding index, or null if no anonymous data sources were found.</returns> /// <seealso cref="ImplicitDataBindingIndexOffset"/> public int?ResolveImplicitDataBindingIndex() { int index = 0; for (PatternTestDataContext currentContext = this; currentContext != null; currentContext = currentContext.parent) { if (currentContext.dataSourceTable != null && currentContext.dataSourceTable.ResolveDataSource("") != null) { return(index); } index += currentContext.implicitDataBindingIndexOffset; } return(null); }
/// <summary> /// Creates a new data context. /// </summary> /// <param name="parent">The containing data context, or null if none.</param> public PatternTestDataContext(PatternTestDataContext parent) { this.parent = parent; }