Ejemplo n.º 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());
        }
Ejemplo n.º 2
0
        public async void TestNodeCrud()
        {
            IBranch branch = await Fixture.Repository.ReadBranchAsync("master");

            JObject nodeObj = new JObject(
                new JProperty("title", "MyNode")
                );
            IBaseNode node = await branch.CreateNodeAsync(nodeObj);

            string expectedRef = "node://" + node.PlatformId + "/" + node.RepositoryId + "/" + node.BranchId + "/" + node.Id;

            Assert.Equal(expectedRef, node.Ref.Ref);

            Assert.NotNull(node.QName);
            Assert.Equal("n:node", node.TypeQName.ToString());

            IBaseNode nodeRead = await branch.ReadNodeAsync(node.Id);

            Assert.Equal(node.Data, nodeRead.Data);

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

            await nodeRead.ReloadAsync();

            Assert.Equal(node.Data["title"], nodeRead.Data["title"]);

            await node.DeleteAsync();

            nodeRead = await branch.ReadNodeAsync(node.Id);

            Assert.Null(nodeRead);
        }
Ejemplo n.º 3
0
        public async void TestChangeQName()
        {
            IBranch master = await Fixture.Repository.MasterAsync();

            JObject nodeObj = new JObject(
                new JProperty("_type", "n:node"),
                new JProperty("title", "Test Node")
                );

            IBaseNode node = await master.CreateNodeAsync(nodeObj);

            await node.ChangeQNameAsync(QName.create("o:blah"));

            await node.ReloadAsync();

            QName newQName = node.QName;

            Assert.Equal("o:blah", newQName.ToString());
        }