Exemplo n.º 1
0
        public void TestCartellaConstructor()
        {
            Cartella c = new Cartella("ABC");

            Assert.AreNotEqual(c, null);
            Assert.AreEqual(c.Path, "ABC");
        }
Exemplo n.º 2
0
 public ImpostazioneTrasferimento(string cartellaSorgente, string cartellaDestinazione)
 {
     if (cartellaSorgente != null)
     {
         if (cartellaSorgente.Length < 261)
         {
             _cartellaSorgente = new Cartella(cartellaSorgente);
         }
         else
         {
             throw new PathNotValidException("Il path della cartella sorgente è troppo lungo");
         }
     }
     else
     {
         throw new PathNotValidException("Il path sorgente è nullo");
     }
     if (cartellaDestinazione != null)
     {
         if (cartellaDestinazione.Length < 261)
         {
             _cartellaDestinazione = cartellaDestinazione;
         }
         else
         {
             throw new PathNotValidException("Il path della cartella destinazione è troppo lungo");
         }
     }
     else
     {
         throw new PathNotValidException("Il path destinazione è nullo");
     }
 }
 public void Visit(Cartella cartella)
 {
     if (cartella.Children.Count > 0)
     {
         //Creo la stringa del path da ricreare
         string dirname   = new DirectoryInfo(cartella.Path).Name;
         string dirToSync = String.Join("\\", _pathDestinazione, dirname);
         //Creo la cartella richiesta se non esiste
         if (!Directory.Exists(dirToSync))
         {
             Directory.CreateDirectory(dirToSync);
             ActionCompletedEvent args = new ActionCompletedEvent
             {
                 ToEntry = EntryFactory.CreateEntry(this, "creata cartella",
                                                    sorgente: cartella.Path, destinazione: dirToSync)
             };
             ToLog?.Invoke(this, args);
         }
         //Memorizzo il vecchio path per quando ho finito di ispezionare i figli
         string oldPath = _pathDestinazione;
         //Il nuovo path è quello di questa cartella
         _pathDestinazione = dirToSync;
         //Entro e sincronizzo le sottocartelle usando il nuovo path
         foreach (FilesystemElement element in cartella.Children)
         {
             element.Accept(this);
         }
         //Ripristino il path vecchio =>(..)
         _pathDestinazione = oldPath;
     }
 }
Exemplo n.º 4
0
        public void TestCartellaAddChild()
        {
            Cartella home    = new Cartella("ABC");
            Cartella subHome = new Cartella("KDE");

            home.AddChild(subHome);
            FilesystemElement toTest = home.GetChild("KDE");

            Assert.AreSame(subHome, toTest);
        }
Exemplo n.º 5
0
        private void buttonSelezionaPath_Click(object sender, EventArgs e)
        {
            DialogResult result = Cartella.ShowDialog();

            if (result == DialogResult.OK)
            {
                String folderName = Cartella.SelectedPath;

                MessageBox.Show("Il percorso selezionato è: " + folderName);
                Properties.Settings.Default.Percorso = folderName;
                Properties.Settings.Default.Save();
            }
        }
Exemplo n.º 6
0
        public void TestPopolamento()
        {
            Cartella dir = new Cartella(@"C:\Users\massi\Desktop\prova");

            Console.WriteLine(dir);
        }
Exemplo n.º 7
0
        public void TestCartellaPathLength()
        {
            Cartella c = new Cartella("ABC");

            Assert.Throws <PathNotValidException>(() => c.Path = _veryLongPath);
        }