Ejemplo n.º 1
0
        private void SetupDatabaseAndTree()
        {
            //standard for all tests is an standard database with the rootGroup and some PwEntries
            m_database = TestHelper.CreateDatabase();

            m_treeManager = new TreeManagerAccessor();
            m_syncManager = new SyncMasterAccessor();
            m_syncManager.Initialize(m_database);
            m_treeManager.Initialize(m_database);
        }
        public void ShouldHandleExportAndImportOfDifferentDatabasesSuccessfully()
        {
            var exportKeeShare = new KeeShare.KeeShare();
            var exportDatabase = TestHelper.CreateDatabase();

            exportKeeShare.Initialize(exportDatabase);

            var treeManagerAccessor = new TreeManagerAccessor();

            treeManagerAccessor.Initialize(exportDatabase);
            treeManagerAccessor.CreateNewUser("MrX");
            exportKeeShare.EnsureValidTree(exportDatabase);

            var userNode        = TestHelper.GetUserRootNodeByNameFor(exportDatabase, "MrX");
            var userHome        = TestHelper.GetUserHomeNodeByNameFor(exportDatabase, "MrX");
            var exportRootEntry = new PwEntry(true, true);

            exportRootEntry.SetTitle("ExportRootEntry");
            exportDatabase.RootGroup.AddEntry(exportRootEntry, true);

            var exportPath = GetTestPath();
            var exportFile = exportPath + SyncSource.FileNameFor(userNode) + SyncExporter.FileExtension;

            exportKeeShare.AddExportPath(exportPath);
            var exportTarget = exportDatabase.GetExportGroup().Groups.GetAt(0);

            exportTarget.AddEntry(userNode.CreateProxyNode(), true);

            var exportHomeEntry = new PwEntry(true, true);

            exportHomeEntry.SetTitle("ExportHomeEntry");
            userHome.AddEntry(exportHomeEntry, true);
            exportDatabase.RootGroup.AddEntry(userNode.CreateProxyNode(), true);

            var importDatabase = TestHelper.CreateDatabase();
            var importKeeShare = new KeeShare.KeeShare();

            importKeeShare.Initialize(importDatabase);

            exportKeeShare.Export();

            importKeeShare.AddImportPath(exportFile);
            var importGroup  = importDatabase.GetImportGroup().Groups.GetAt(0);
            var importSource = importGroup.Entries.GetAt(0);

            importSource.SetPassword(userNode.Strings.ReadSafe(KeeShare.KeeShare.PasswordField));

            importKeeShare.EnsureValidTree(importDatabase);

            Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportRootEntry"));
            Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportHomeEntry"));
        }
        public void ShouldHandleExportAndImportOfDifferentDatabasesSuccessfully()
        {
            var exportKeeShare = new KeeShare.KeeShare();
            var exportDatabase = TestHelper.CreateDatabase();
            exportKeeShare.Initialize(exportDatabase);

            var treeManagerAccessor = new TreeManagerAccessor();
            treeManagerAccessor.Initialize(exportDatabase);
            treeManagerAccessor.CreateNewUser("MrX");
            exportKeeShare.EnsureValidTree(exportDatabase);

            var userNode = TestHelper.GetUserRootNodeByNameFor(exportDatabase, "MrX");
            var userHome = TestHelper.GetUserHomeNodeByNameFor(exportDatabase, "MrX");
            var exportRootEntry = new PwEntry(true, true);
            exportRootEntry.SetTitle("ExportRootEntry");
            exportDatabase.RootGroup.AddEntry(exportRootEntry, true);

            var exportPath = GetTestPath();
            var exportFile = exportPath + SyncSource.FileNameFor(userNode) + SyncExporter.FileExtension;
            exportKeeShare.AddExportPath(exportPath);
            var exportTarget = exportDatabase.GetExportGroup().Groups.GetAt(0);
            exportTarget.AddEntry(PwNode.CreateProxyNode(userNode), true);

            var exportHomeEntry = new PwEntry(true, true);
            exportHomeEntry.SetTitle("ExportHomeEntry");
            userHome.AddEntry(exportHomeEntry, true);
            exportDatabase.RootGroup.AddEntry(PwNode.CreateProxyNode(userNode), true);

            var importDatabase = TestHelper.CreateDatabase();
            var importKeeShare = new KeeShare.KeeShare();
            importKeeShare.Initialize(importDatabase);

            exportKeeShare.Export();

            importKeeShare.AddImportPath(exportFile);
            var importGroup = importDatabase.GetImportGroup().Groups.GetAt(0);
            var importSource = importGroup.Entries.GetAt(0);
            importSource.SetPassword(userNode.Strings.ReadSafe(KeeShare.KeeShare.PasswordField));

            importKeeShare.EnsureValidTree(importDatabase);

            Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportRootEntry"));
            Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportHomeEntry"));
        }
 public void TestInit()
 {
     //standard for all tests is an empty database with only the copyRootGroup in it (no PwEntries)
     m_database = TestHelper.CreateDatabase("recycler");
     m_treeManager = new TreeManagerAccessor();
 }
 public void TestCleanup()
 {
     m_database = null;
     m_treeManager = null;
 }
        private void SetupDatabaseAndTree()
        {
            //standard for all tests is an standard database with the rootGroup and some PwEntries
            m_database = TestHelper.CreateDatabase();

            m_treeManager = new TreeManagerAccessor();
            m_syncManager = new SyncMasterAccessor();
            m_syncManager.Initialize(m_database);
            m_treeManager.Initialize(m_database);
        }
Ejemplo n.º 7
0
 public void TestCleanup()
 {
     m_database    = null;
     m_treeManager = null;
 }
Ejemplo n.º 8
0
 public void TestInit()
 {
     //standard for all tests is an empty database with only the copyRootGroup in it (no PwEntries)
     m_database    = TestHelper.CreateDatabase("recycler");
     m_treeManager = new TreeManagerAccessor();
 }