public void CopyImages_GivenValidsPaths_ReturnStatusSuccess() { //arrange DirectoryService service = new DirectoryService(""); string fromDirectory = "fromDirectory"; string toDirectory = "toDirectory"; Directory.CreateDirectory(fromDirectory); Directory.CreateDirectory(toDirectory); string imgName = "img.jpg"; string img = Path.Combine(fromDirectory, imgName); using (FileStream fs = File.Create(img)) { for (byte i = 0; i < 10; i++) { fs.WriteByte(i); } } //act DirectoryStatus d = service.CopyImages(fromDirectory, toDirectory); //assert d.Should().Be(DirectoryStatus.Success); Directory.Delete(fromDirectory, true); Directory.Delete(toDirectory, true); }
static void Main(string[] args) { DirectoryService service = new DirectoryService("C:/"); Console.WriteLine("Criando Diretório..."); var code = service.CreateNewDirectory("to"); if (code == DirectoryStatus.Failed) { Console.WriteLine("Falha ao criar o diretório."); return; } Console.WriteLine("Copiando Imagens..."); code = service.CopyImages("from", "to"); if (code == DirectoryStatus.Inexistent) { Console.WriteLine("Verifique se os diretórios informados existem."); return; } else if (code == DirectoryStatus.Failed) { Console.WriteLine("Falha ao copiar as imagens."); return; } Console.WriteLine("Arquivos copiados com sucesso."); }
public void CopyImages_GivenInvalidFromPath_ReturnStatusInexistent() { //arrange DirectoryService service = new DirectoryService(""); string fromDirectory = "fromDirectory"; string toDirectory = "toDirectory"; //act DirectoryStatus d = service.CopyImages(fromDirectory, toDirectory); //assert d.Should().Be(DirectoryStatus.Inexistent); }