public void DeleteWithError() { using (var testDirectory = new Infrastructure.TestDirectory()) { var sourceFile = Path.Combine(testDirectory.FullPath, Guid.NewGuid().ToString()); File.WriteAllBytes(sourceFile, new byte[0]); var file = new DirectorySync.Models.File(sourceFile); string error = null; file.SyncErrorEvent += (string message) => { error = message; }; using (var stream = File.Open(sourceFile, FileMode.Open)) file.Delete().Wait(); Assert.NotNull(error); } }
public void Delete(bool isReadOnly) { IItem deletedFile = null; using (var testDirectory = new Infrastructure.TestDirectory()) { var sourceFile = Path.Combine(testDirectory.FullPath, Guid.NewGuid().ToString()); File.WriteAllBytes(sourceFile, new byte[0]); new FileInfo(sourceFile).IsReadOnly = isReadOnly; var file = new DirectorySync.Models.File(sourceFile); file.DeletedEvent += (IItem item) => { deletedFile = item; }; file.Delete().Wait(); Assert.Equal(file, deletedFile); Assert.False(File.Exists(sourceFile)); } }