示例#1
0
        public async Task Unpublish_EndToEnd()
        {
            // Query only 'sees' published records so that is a quick way to determine publish state
            // - insert some records
            // - publish them
            // - un publish them
            // - assert there are none (because we unpublished them)

            var schemaName = GetRandomName;
            await SchemaClient.AssertNoSchemasExist("aut", delay : TimeSpan.FromSeconds(0.5));

            var createschema = await SchemaClient.CreateSchema("aut", AssetLoader.Schema1(schemaName));

            var publishedschema = await SchemaClient.PublishSchema("aut", schemaName);

            dynamic create1response = await ContentClient.CreateContent("aut", schemaName, AssetLoader.AsDynamic(AssetLoader.Schema1Data1PostName));

            dynamic create2response = await ContentClient.CreateContent("aut", schemaName, AssetLoader.AsDynamic(AssetLoader.Schema1Data2PostName));

            string create1id = Convert.ToString(create1response.id);
            string create2id = Convert.ToString(create2response.id);

            await Task.Delay(TimeSpan.FromSeconds(1));

            await ContentClient.PublishContent("aut", schemaName, create1id);

            await ContentClient.PublishContent("aut", schemaName, create2id);

            // act

            // note : eventual consistency and all that sometimes we don't get away with validating right away.

            await Task.Delay(TimeSpan.FromSeconds(1));

            await ContentClient.UnpublishContent("aut", schemaName, create1id);

            await ContentClient.UnpublishContent("aut", schemaName, create2id);

            await Task.Delay(TimeSpan.FromSeconds(1));

            //var content = await ContentClient.Query<dynamic>("aut", schemaName, new QueryRequest()
            //{
            //  Skip = 0,
            //  Top = 100
            //});
            var content = await ContentClient.QueryContent("aut", schemaName, top : 100, skip : 0);

            int contenttotal = Convert.ToInt32(content.total);

            contenttotal.Should().Be(0);

            // clean up

            await SchemaClient.DeleteSchema("aut", schemaName);
        }