public void blog_add_query_request() { var d = AutofacStoreFactory.AutofacContainer; var dd = AutofacStoreFactory.Resolve <IMutationFieldRecordRegistration>(); var cc = AutofacStoreFactory.Resolve <IMutationFieldRecordRegistrationStore>(); var timeStamp = DateTime.UtcNow.ToSecondResolution(); var tsS = timeStamp.ToString(JsonDocumentWriter.JsonSerializerSettings.DateFormatString); var simpleTS = DateTime.Parse(tsS, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); var blogEntry = new SimpleDocument <Blog>() { MetaData = new MetaData() { Category = "c0", Version = "1.0.0.0" }, Document = new Blog() { Categories = new List <string>() { "c1", "c2" }, Tags = new List <string>() { "t1", "t2" }, Data = "This is my blog", TimeStamp = timeStamp, Summary = "My Summary", Title = "My Title" }, Id = Guid.NewGuid().ToString() }; var jsonBlog = JsonDocumentWriter.SerializeObjectSingleQuote(blogEntry); 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); rawInput = $"{{'input': {{'id':'{blogEntry.Id.ToString()}' }} }}"; 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); 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); blogEntry.TenantId = resultBlogDocument.TenantId; resultBlogDocument.TenantId = blogEntry.TenantId; resultBlogDocument.Document.EnableDeepCompare = blogEntry.Document.EnableDeepCompare; string additionalInfo = null; blogEntry.Document.EnableDeepCompare = true; resultBlogDocument.Document.EnableDeepCompare = true; resultBlogDocument.ShouldBe(blogEntry, additionalInfo); }
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; }