public override async Task InitializeAsync() { await base.InitializeAsync(); await DisposeAsync(); var current = await Contents.GetAsync(new ContentQuery { Top = 0 }); var countTotal = (int)current.Total; var countMissing = 100 - countTotal; for (var index = countMissing; index > 0; index--) { var data = new TestEntityData { Number = index, Json = JObject.FromObject(new { nested0 = index, nested1 = new { nested2 = index } }), String = index.ToString(CultureInfo.InvariantCulture) }; await Contents.CreateAsync(data, ContentCreateOptions.AsPublish); } }
protected ContentQueryFixture1to10(string schemaName = "my-schema") : base(schemaName) { Task.Run(async() => { Dispose(); for (var i = 10; i > 0; i--) { var data = new TestEntityData { Number = i, String = i.ToString() }; if (i % 2 == 0) { data.Geo = new { type = "Point", coordinates = new[] { i, i } }; } else { data.Geo = new { longitude = i, latitude = i }; } await Contents.CreateAsync(data, true); } }).Wait(); }
protected ContentQueryFixture1to10(string schemaName = "my-schema") : base(schemaName) { Task.Run(async() => { #pragma warning disable MA0056 // Do not call overridable members in constructor Dispose(); #pragma warning restore MA0056 // Do not call overridable members in constructor for (var i = 10; i > 0; i--) { var text = i.ToString(CultureInfo.InvariantCulture); var data = new TestEntityData { Number = i, String = text }; if (i % 2 == 0) { data.Geo = new { type = "Point", coordinates = new[] { i, i } }; } else { data.Geo = new { longitude = i, latitude = i }; } await Contents.CreateAsync(data, true); } }).Wait(); }
public async Task Should_cleanup_old_data_from_update_response() { var schemaName = $"schema-{DateTime.UtcNow.Ticks}"; // STEP 1: Create a schema. var schema = await TestEntity.CreateSchemaAsync(_.Schemas, _.AppName, schemaName); var contents = _.ClientManager.GetClient <TestEntity, TestEntityData>(schemaName); // STEP 2: Create a content for this schema. var data = new TestEntityData { Number = 12, String = "hello" }; var content_1 = await contents.CreateAsync(data); Assert.Equal(data.String, content_1.Data.String); // STEP 3: Delete a field from schema. await _.Schemas.DeleteFieldAsync(_.AppName, schema.Name, schema.Fields.ElementAt(1).FieldId); // STEP 4: Make any update. var content_2 = await contents.ChangeStatusAsync(content_1.Id, "Published"); // Should not return deleted field. Assert.Null(content_2.Data.String); }
public override async Task InitializeAsync() { await base.InitializeAsync(); await DisposeAsync(); for (var index = 10; index > 0; index--) { var data = new TestEntityData { Number = index, Json = JObject.FromObject(new { nested1 = new { nested2 = index } }), Geo = GeoJson.Point(index, index, oldFormat: index % 2 == 1), Localized = new Dictionary <string, string> { ["en"] = index.ToString(CultureInfo.InvariantCulture) }, String = index.ToString(CultureInfo.InvariantCulture), }; await Contents.CreateAsync(data, ContentCreateOptions.AsPublish); } }