/// <summary> /// Creates a session around the specified browser. /// </summary> public Session(Browser browser) { Browser = browser; Finders = FindExtensions.DefaultFinders().ToList(); Timeout = TimeSpan.FromSeconds(30); Logger = new ConsoleLogger(); }
public ODataQueryTests() { A.CallTo(() => tagService.GetTagIdsAsync(appId, TagGroups.Assets, A <HashSet <string> > .That.Contains("tag1"))) .Returns(HashSet.Of("normalized1")); valueConverter = FindExtensions.CreateValueConverter(appId, tagService); }
public async Task <IResultList <IContentEntity> > QueryAsync(IAppEntity app, ISchemaEntity schema, Status[] status, ODataUriParser odataQuery, bool latest = false) { try { IMongoCollection <MongoContentEntity> sourceCollection; if (latest) { sourceCollection = LatestCollection; } else { sourceCollection = Collection; } var propertyCalculator = FindExtensions.CreatePropertyCalculator(schema.SchemaDef); var filter = FindExtensions.BuildQuery(odataQuery, schema.Id, status, propertyCalculator); var contentCount = sourceCollection.Find(filter).CountAsync(); var contentItems = sourceCollection.Find(filter) .ContentTake(odataQuery) .ContentSkip(odataQuery) .ContentSort(odataQuery, propertyCalculator) .ToListAsync(); await Task.WhenAll(contentItems, contentCount); foreach (var entity in contentItems.Result) { entity.ParseData(schema.SchemaDef); } return(ResultList.Create <IContentEntity>(contentItems.Result, contentCount.Result)); } catch (NotSupportedException) { throw new ValidationException("This odata operation is not supported."); } catch (NotImplementedException) { throw new ValidationException("This odata operation is not supported."); } catch (MongoQueryException ex) { if (ex.Message.Contains("17406")) { throw new DomainException("Result set is too large to be retrieved. Use $top parameter to reduce the number of items."); } else { throw; } } }
private string F(string value) { var parser = edmModel.ParseQuery(value); var query = parser.BuildFilter <MongoContentEntity>(FindExtensions.CreatePropertyCalculator(schemaDef)) .Filter.Render(serializer, registry).ToString(); return(query); }
private string S(string value) { var parser = edmModel.ParseQuery(value); var cursor = A.Fake <IFindFluent <MongoContentEntity, MongoContentEntity> >(); var i = string.Empty; A.CallTo(() => cursor.Sort(A <SortDefinition <MongoContentEntity> > .Ignored)) .Invokes((SortDefinition <MongoContentEntity> sortDefinition) => { i = sortDefinition.Render(serializer, registry).ToString(); }); cursor.ContentSort(parser, FindExtensions.CreatePropertyCalculator(schemaDef)); return(i); }
public async Task <IResultList <IAssetEntity> > QueryAsync(Guid appId, string query = null) { using (Profiler.TraceMethod <MongoAssetRepository>("QueryAsyncByQuery")) { try { var odataQuery = EdmAssetModel.Edm.ParseQuery(query); var filter = FindExtensions.BuildQuery(odataQuery, appId, tagService); var contentCount = Collection.Find(filter).CountDocumentsAsync(); var contentItems = Collection.Find(filter) .AssetTake(odataQuery) .AssetSkip(odataQuery) .AssetSort(odataQuery) .ToListAsync(); await Task.WhenAll(contentItems, contentCount); return(ResultList.Create <IAssetEntity>(contentCount.Result, contentItems.Result)); } catch (NotSupportedException) { throw new ValidationException("This odata operation is not supported."); } catch (NotImplementedException) { throw new ValidationException("This odata operation is not supported."); } catch (MongoQueryException ex) { if (ex.Message.Contains("17406")) { throw new DomainException("Result set is too large to be retrieved. Use $top parameter to reduce the number of items."); } else { throw; } } } }
public async Task <IResultList <IContentEntity> > QueryAsync(IAppEntity app, ISchemaEntity schema, Query query, Status[] status = null, bool useDraft = false) { try { query = query.AdjustToModel(schema.SchemaDef, useDraft); var filter = FindExtensions.BuildQuery(query, schema.Id, status); var contentCount = Collection.Find(filter).CountDocumentsAsync(); var contentItems = Collection.Find(filter) .ContentTake(query) .ContentSkip(query) .ContentSort(query) .Not(x => x.DataText) .ToListAsync(); await Task.WhenAll(contentItems, contentCount); foreach (var entity in contentItems.Result) { entity.ParseData(schema.SchemaDef); } return(ResultList.Create <IContentEntity>(contentCount.Result, contentItems.Result)); } catch (MongoQueryException ex) { if (ex.Message.Contains("17406")) { throw new DomainException("Result set is too large to be retrieved. Use $top parameter to reduce the number of items."); } else { throw; } } }