public virtual void RunModel() { QueryModel model = new QueryModel(_workspace, _kind, null); ModelEngine engine = new ModelEngine(model); engine.Options.WeightScheme = WeightScheme.Custom; engine.Options.Timeout = 100; engine.RunUntil(delegate() { return model.Actions.Accessed > 5; }); _query = model.QueryResult; _container = model.ResContainer; _pType = model.ResultType; if (_query != null || _pType != null) { switch (_queryType) { case "server": VerifyServer(_query); break; case "client": VerifyClient(model); break; case "linq": VerifyClientLinq(model); break; } } }
//Constructor public QueryModel(Workspace workspace, SerializationFormatKind kind, QueryModel parent) : base( parent ) { _workspace = workspace; _kind = kind; _parent = parent; }
//Constructor public ExpressionsModel(QueryModel parent) : base(parent) { }
public void VerifyClientLinq(QueryModel qm) { try { ExecuteLinq(qm.Workspace, qm.QueryResult, qm.ResContainer); } catch (Exception e) { AstoriaTestLog.FailAndContinue(e); } }
public void VerifyClient(QueryModel qm) { WebDataCtxWrapper ctx = new WebDataCtxWrapper(new Uri(qm.Workspace.ServiceUri)); ctx.Credentials = CredentialCache.DefaultNetworkCredentials; try { UriQueryBuilder ub = new UriQueryBuilder(qm.Workspace, ""); string ruri = ub.Build(qm.QueryResult); string uriRel = ruri.Substring(ruri.LastIndexOf(".svc/") + 5); if ((ctx.BaseUri + "/" + uriRel).Length > 260) { return; } AstoriaTestLog.WriteLineIgnore(ctx.BaseUri + "/" + uriRel); ResolveClientType(qm.Workspace, ctx, qm.ResultType); object enumerable = ExecuteQuery(ctx, qm.ResultType, uriRel, "sync"); Verify(qm.Workspace, qm.QueryResult, (IEnumerable)enumerable, qm.ResType, null, qm.IsCount); } catch (Exception e) { AstoriaTestLog.FailAndContinue(e); } }
public virtual void DirectedTests() { QueryModel model = new QueryModel(_workspace, SerializationFormatKind.Atom, null); ModelEngine engine = new ModelEngine(model); engine.Options.WeightScheme = WeightScheme.Custom; engine.Options.Timeout = 100; engine.RunUntil(delegate() { return engine.Models.Actions.AllCovered; }); //engine.RunScenario(model.Actions.Find("From", "Where", " Navigation","Select","Expand")); //engine.RunUntil(delegate() //{ // return model.Actions.Accessed > 4; //}); _query = model.QueryResult; _container = model.ResContainer; _pType = model.ResultType; if (_query != null || _pType != null) { VerifyClient(model); } }
public void QueryEntities() { string entitySetName = ""; object entity = null; ResourceContainer resContainer = null; while (resContainer == null) { entity = GetResource(out entitySetName, out resContainer); } QueryModel queryModel = new QueryModel(workSpace, SerializationFormatKind.Atom, null); queryModel.RunningUnderScenarioModel = true; queryModel.ResContainer = resContainer; ModelEngine engine = new ModelEngine(queryModel); engine.Options.WeightScheme = WeightScheme.Custom; engine.Options.Timeout = Timeout; engine.Run(); UriQueryBuilder ub = new UriQueryBuilder(workSpace, ""); string ruri = ub.Build(queryModel.QueryResult); string uriRel = ruri.Substring(ruri.LastIndexOf(".svc/") + 5); if ((Context.BaseUri + "/" + uriRel).Length > 260) { return; } AstoriaTestLog.WriteLineIgnore(Context.BaseUri + "/" + uriRel); ResolveClientType(workSpace, Context, queryModel.ResultType); object enumerable = ExecuteQuery(Context, queryModel.ResultType, uriRel, "sync"); }