public void blog_basic_paging_request_by_number() { BlogEntries.Count.ShouldBe(10); var pageSize = 3; var currentIndex = 0; var count = 0; int page = 1; bool keepGoing = true; do { var rawInput2 = $"{{'input': {{'pageSize':{pageSize},'page':{page} }} }}"; var gqlInputs2 = rawInput2.ToInputs(); var query2 = @"query Q($input: blogsPageQueryInput!) { blogsPageByNumber(input: $input){ tenantId id metaData { category version } document{ title summary categories tags timeStamp data } } }"; var runResult2 = ExecuteQuery(query2, gqlInputs2, root: null, userContext: GraphQLUserContext); bool bRun2 = runResult2.Errors?.Any() == true; Assert.IsFalse(bRun2); var slice = BlogEntries.Skip(currentIndex).Take(pageSize).ToList(); foreach (var item in slice) { item.Document.EnableDeepCompare = true; } Dictionary <string, object> result = (Dictionary <string, object>)runResult2.Data; var resultJson = JsonConvert.SerializeObject(result["blogsPageByNumber"]); var blogs = JsonConvert.DeserializeObject <List <SimpleDocument <Blog> > >(resultJson); var read = blogs; slice.ShouldBe(read); blogs.Count.ShouldBe(slice.Count); count += read.Count; currentIndex += pageSize; keepGoing = blogs.Count != 0; page = page + 1; } while (keepGoing); System.Diagnostics.Debug.WriteLine("Count:" + count); count.ShouldBe(BlogEntries.Count); }
protected void Page_Load(object sender, System.EventArgs e) { Response.ContentType = "text/xml"; if (Request.QueryString["blog"] != "") { BlogEntries beEntries = new BlogEntries(); if (!string.IsNullOrEmpty(Request.QueryString["blog"])) beEntries.BlogID = Convert.ToInt64(Request.QueryString["blog"]); beEntries.Page = this; ltr_rss.Text = beEntries.GetRssFeed(); } }
public void blog_timestamp_upper_boundary_paging_request() { BlogEntries.Count.ShouldBe(10); var timestampUpperBoundary = BlogEntries[3].Document.TimeStamp; var tsAsString = timestampUpperBoundary.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"); // ASK FOR THEM ALL var pageSize = BlogEntries.Count; var rawInput2 = $"{{'input': {{'pageSize':'{pageSize}','timestampUpperBoundary':'{tsAsString}' }} }}"; var gqlInputs2 = rawInput2.ToInputs(); var query2 = @"query Q($input: blogsQueryInput!) { blogsPage(input: $input){ currentPagingState pagingState blogs { tenantId id metaData { category version } document{ title summary categories tags timeStamp data } } } }"; var runResult2 = ExecuteQuery(query2, gqlInputs2, root: null, userContext: GraphQLUserContext); var bRun2 = runResult2.Errors?.Any() == true; Assert.IsFalse(bRun2); var slice = BlogEntries.Skip(0).Take(4).ToList(); foreach (var item in slice) { item.Document.EnableDeepCompare = true; } Dictionary <string, object> result = (Dictionary <string, object>)runResult2.Data; var resultJson = JsonConvert.SerializeObject(result["blogsPage"]); var blogPage = JsonConvert.DeserializeObject <BlogPage>(resultJson); var read = blogPage.Blogs; slice.ShouldBe(read); blogPage.Blogs.Count.ShouldBe(slice.Count); }
List <SimpleDocument <Blog> > CreateBlogEntries(int nCount) { if (this.BlogEntries == null) { this.BlogEntries = new EditableList <SimpleDocument <Blog> >(); var dtBase = DateTime.UtcNow.ToSecondResolution(); dtBase = dtBase.AddYears(10); var tsS = dtBase.ToString(JsonDocumentWriter.JsonSerializerSettings.DateFormatString); dtBase = DateTime.Parse(tsS, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); int timeMultipier = 1; for (int i = 0; i < 10; ++i) { timeMultipier = timeMultipier * -1; DateTime timeStamp = dtBase.AddMinutes(i * timeMultipier); int n = i % 2; SimpleDocument <Blog> simpleBlogDocument = new SimpleDocument <Blog>() { MetaData = new MetaData() { Category = "c0", Version = "1.0.0.0" }, Document = new Blog() { Categories = new List <string>() { "c1" + n, "c2" + i }, Tags = new List <string>() { "t1" + n, "t2" + i }, Data = "This is my blog", TimeStamp = timeStamp, Summary = "My Summary", Title = "My Title" }, Id = Guid.NewGuid().ToString() }; BlogEntries.Add(simpleBlogDocument); } } return(BlogEntries); }
public static BlogEntryModel MaptoBlogEntryModel(this BlogEntries blogEntryModel) { var blogEntryMapped = new BlogEntryModel { BId = blogEntryModel.BId, Title = blogEntryModel.Title, Content = blogEntryModel.Content, Date = blogEntryModel.Date, Sender = blogEntryModel.Sender, Section = blogEntryModel.Section, }; return(blogEntryMapped); }
public static BlogEntries MapToBlogEntity(this BlogEntryModel blogPost) { //Nytt objekt av Profilemodel med NOT NULL data. var blogEntry = new BlogEntries { Title = blogPost.Title, Content = blogPost.Content, Date = blogPost.Date, Sender = blogPost.Sender, Section = blogPost.Section }; return(blogEntry); }
public void blog_basic_paging_request() { BlogEntries.Count.ShouldBe(10); var pageSize = 3; var currentIndex = 0; var count = 0; byte[] pagingState = null; byte[] currentPagingState = null; bool keepGoing = true; do { var rawInput2 = $"{{'input': {{'pageSize':'{pageSize}','pagingState':'{pagingState.SafeConvertToBase64String()}' }} }}"; var gqlInputs2 = rawInput2.ToInputs(); var query2 = @"query Q($input: blogsQueryInput!) { blogsPage(input: $input){ currentPagingState pagingState blogs { tenantId id metaData { category version } document{ title summary categories tags timeStamp data } } } }"; var runResult2 = ExecuteQuery(query2, gqlInputs2, root: null, userContext: GraphQLUserContext); bool bRun2 = runResult2.Errors?.Any() == true; Assert.IsFalse(bRun2); var slice = BlogEntries.Skip(currentIndex).Take(pageSize).ToList(); foreach (var item in slice) { item.Document.EnableDeepCompare = true; } Dictionary <string, object> result = (Dictionary <string, object>)runResult2.Data; var resultJson = JsonConvert.SerializeObject(result["blogsPage"]); var blogPage = JsonConvert.DeserializeObject <BlogPage>(resultJson); var read = blogPage.Blogs; slice.ShouldBe(read); pagingState = blogPage.PagingState.SafeConvertFromBase64String(); currentPagingState = blogPage.CurrentPagingState.SafeConvertFromBase64String(); count += read.Count; currentIndex += pageSize; keepGoing = pagingState != null; } while (keepGoing); System.Diagnostics.Debug.WriteLine("Count:" + count); count.ShouldBe(BlogEntries.Count); }
void InsertBlogEntriesIntoStore(int count) { if (!Inserted) { CreateBlogEntries(count); var pluginValidationRules = AutofacStoreFactory.Resolve <IEnumerable <IPluginValidationRule> >(); foreach (var blogEntry in BlogEntries) { var jsonBlog = JsonDocumentWriter.SerializeObjectSingleQuote(blogEntry); Dictionary <string, object> values = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonBlog); var rawInput = $"{{'input': {jsonBlog} }}"; var gqlInputs = rawInput.ToInputs(); var mutation = @" mutation Q($input: blogMutationInput!) { blog(input: $input) }"; var expected = @"{'blog':true}"; AssertQuerySuccess(mutation, expected, gqlInputs, root: null, userContext: GraphQLUserContext, rules: pluginValidationRules); rawInput = $"{{'input': {{ 'id':'{blogEntry.Id}' }} }}"; gqlInputs = rawInput.ToInputs(); var query = @"query Q($input: blogQueryInput!) { blog(input: $input){ tenantId id metaData { category version } document{ title summary categories tags timeStamp data } } }"; var runResult = ExecuteQuery(query, gqlInputs, root: null, userContext: GraphQLUserContext, rules: pluginValidationRules); bool bErrors = runResult.Errors?.Any() == true; Assert.IsFalse(bErrors); Dictionary <string, object> data = (Dictionary <string, object>)runResult.Data; var resultJson = JsonConvert.SerializeObject(data["blog"]); SimpleDocument <Blog> resultBlogDocument = JsonConvert.DeserializeObject <SimpleDocument <Blog> >(resultJson); resultBlogDocument.TenantId = blogEntry.TenantId; resultBlogDocument.Document.EnableDeepCompare = blogEntry.Document.EnableDeepCompare; string additionalInfo = null; blogEntry.Document.EnableDeepCompare = true; resultBlogDocument.ShouldBe(blogEntry, additionalInfo); } BlogEntries = BlogEntries.OrderBy(o => o.Document.TimeStamp).ToList(); foreach (var item in BlogEntries) { item.Document.EnableDeepCompare = true; } } Inserted = true; }
public void DeleteBlogEntry(int id) { BlogEntries.RemoveAll(b => b.EntryId == id); }
public void AddBlogEntry(BlogEntry blog) { blog.EntryId = BlogEntries.Any() ? BlogEntries.Max(b => b.EntryId) + 1 : 1; BlogEntries.Add(blog); }
public BlogEntry GetBlogEntryById(int id) { return(BlogEntries.FirstOrDefault(b => b.EntryId == id)); }