Exemple #1
0
        public async Task Restore_EndToEnd()
        {
            // Query only 'sees' published records so that is a quick way to determine publish state
            // - insert some records
            // - publish them
            // - archive them
            // - assert there are none (because we archived 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);

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

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

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

            await ContentClient.PublishContent("aut", schemaName, create1response.Id);

            await ContentClient.PublishContent("aut", schemaName, create2response.Id);

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

            await ContentClient.ArchiveContent("aut", schemaName, create1response.Id);

            await ContentClient.ArchiveContent("aut", schemaName, create2response.Id);

            // 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.RestoreContent("aut", schemaName, create1response.Id);

            await ContentClient.RestoreContent("aut", schemaName, create2response.Id);

            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);

            // ma
            content.Total.Should().Be(2);

            // clean up

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