コード例 #1
0
        public async void TestVersions()
        {
            IBranch master = await Fixture.Repository.MasterAsync();

            JObject nodeObj = new JObject(
                new JProperty("title", "Test Node")
                );

            IBaseNode node = await master.CreateNodeAsync(nodeObj);

            string firstChangeset = node.Data.SelectToken("_system.changeset").ToString();

            node.Data["title"] = "new stuff";
            await node.UpdateAsync();

            await node.ReloadAsync();

            Assert.Equal("new stuff", node.Data.GetValue("title").ToString());

            List <IBaseNode> versions = await node.ListVersionsAsync();

            Assert.Equal(2, versions.Count);

            IBaseNode firstVersion = await node.ReadVersionAsync(firstChangeset);

            Assert.Equal("Test Node", firstVersion.Data["title"].ToString());

            IBaseNode restoredVersion = await node.RestoreVersionAsync(firstChangeset);

            Assert.Equal("Test Node", restoredVersion.Data["title"].ToString());
        }