// Import one file and update new items and unresolved links
        private void ImportItem(ReplicatedItem item)
        {
            try
            {
                var record = _repstore.SyncItem(item);
                _stillUnresolved.AddRange(record.UnresolvedLinks);

                foreach (var ri in record.ReadItems)
                {
                    _newItems[ri.ID] = ri;
                }
            }
            catch (Exception e)
            {
                _logger.Error("IMPORT Error: " + e.Message, e);
                _journal.Log(e.Message);
            }
        }
Ejemplo n.º 2
0
        public void RepStorage_CanWriteAndRead()
        {
            Assert.AreEqual(0, Storage.GetItems().Count());

            // create an item and export
            ContentItem root = CreateOneItem <TestItem>(0, "root", null);

            Storage.ExportItem(root);

            // check export worked
            Assert.AreEqual(1, Storage.GetItems().Count());
            var ri = Storage.GetItems().Single();

            Assert.AreEqual(root.ID, ri.ID);

            // check timestamps are accurate
            Assert.That(ri.PublishedDateEquals(root.Published.Value));

            // check import works
            var import = Storage.SyncItem(ri);

            Assert.AreEqual(0, import.Attachments.Count);
            Assert.AreEqual(0, import.Errors.Count);
            Assert.AreEqual(0, import.FailedAttachments.Count);
            Assert.AreEqual(0, import.UnresolvedLinks.Count);
            Assert.AreEqual(1, import.ReadItems.Count);
            //     Assert.That(root == import.RootItem); // use overloaded equality
            //     Assert.That(import.RootItem == import.ReadItems.Single()); // use overloaded equality

            // check delete works
            Storage.DeleteItem(ri);
            Assert.AreEqual(0, Storage.GetItems().Count());

            Storage.ExportItem(root);
            var files = Storage.GetItems();

            Assert.AreEqual(1, files.Count());

            // check delete by ID works
            Storage.DeleteItem(root.ID);
            Assert.AreEqual(0, Storage.GetItems().Count());
        }