Ejemplo n.º 1
0
        public void ReadSettings()
        {
            _currentTest = Path.Combine(CurrentWorkingFolder, "test6");

            EnsureFolderExists(_currentTest);

            var sourceFolder      = "C:\\Music";
            var destinationFolder = "D:\\Backups\\Music";

            _settingsManager.Data.SyncPairs.Add(new SyncPair {
                Source = _currentTest, Destination = _currentTest
            });

            var settingsFile = new KoreFileInfo(Path.Combine(_currentTest, "settings.bin"));

            _kontrol.WriteSettings(settingsFile);

            var settingsManager = new SettingsManager <ISettings>(new BinarySerializer <ISettings>());

            var kontrol = new Kontrol(settingsManager, _syncManager);

            kontrol.ReadSettings(settingsFile);

            Assert.IsNotNull(settingsManager.Data);
            Assert.IsNotNull(settingsManager.Data.SyncPairs);
            Assert.AreEqual(1, settingsManager.Data.SyncPairs.Count);
            Assert.AreEqual(sourceFolder, settingsManager.Data.SyncPairs[0].Source);
            Assert.AreEqual(destinationFolder, settingsManager.Data.SyncPairs[0].Destination);

            Assert.IsTrue(settingsFile.Exists);
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            _settingsFileInfo = new KoreFileInfo("settings.bin");

            _kontrol = new Kontrol(new SettingsManager <ISettings>(new BinarySerializer <ISettings>()),
                                   new Core.SyncManager(new DiffBuilder(new DiffInfoBuilder(), new FileScanner(new FileRetriever()),
                                                                        new FolderDiffer(new IdentityProvider())), new FolderDiffProcessor(new DiffProcessor(new FileCopier())),
                                                        new SyncInfo()));

            _kontrol.ReadSettings(_settingsFileInfo);

            InitializeComponent();

            sourceFiles.DataContext      = _kontrol.SyncInfo;
            destinationFiles.DataContext = _kontrol.SyncInfo;
            syncStatus.DataContext       = _kontrol.SyncInfo;

            Closing += (sender, args) => { _kontrol.WriteSettings(_settingsFileInfo); };
        }