public void FileConnectorSaveStream3Test() { FileSystemConnector fileSystemConnector = new FileSystemConnector(@".", "wrong"); using (var fileStream = System.IO.File.OpenRead(@".\resources\custombg.jpg")) { fileSystemConnector.SaveFileStream("blabla.png", @"Resources\Templates", fileStream); } long byteCount = 0; using (var fileStream = System.IO.File.OpenRead(@".\resources\office365.png")) { byteCount = fileStream.Length; fileSystemConnector.SaveFileStream("blabla.png", @"Resources\Templates", fileStream); } //read the file using (var bytes = fileSystemConnector.GetFileStream("blabla.png", @"Resources\Templates")) { Assert.IsTrue(byteCount == bytes.Length); } // file will be deleted at end of test }
public void FileConnectorDelete2Test() { // upload the file FileSystemConnector fileSystemConnector = new FileSystemConnector(@".", "wrong"); using (var fileStream = System.IO.File.OpenRead(@".\resources\office365.png")) { fileSystemConnector.SaveFileStream("blabla.png", @"Resources\Templates", fileStream); } // delete the file fileSystemConnector.DeleteFile("blabla.png", @"Resources\Templates"); //read the file using (var bytes = fileSystemConnector.GetFileStream("blabla.png", @"Resources\Templates")) { Assert.IsNull(bytes); } // file will be deleted at end of test }
public void FileConnectorForwardslashSupportTest() { // Path with forwardslash separator var filename = "separator.png"; var containerWithForwardSlash = @"Resources/Templates/newfolder"; // Constructor replaces folder delimiter FileSystemConnector fileSystemConnector = new FileSystemConnector(".", containerWithForwardSlash); Assert.AreEqual(@"Resources\Templates\newfolder", fileSystemConnector.GetContainer()); // Save a file long byteCount = 0; using (var fileStream = System.IO.File.OpenRead(@".\resources\office365.png")) { byteCount = fileStream.Length; fileSystemConnector.SaveFileStream(filename, containerWithForwardSlash, fileStream); } // List files var files = fileSystemConnector.GetFiles(containerWithForwardSlash); Assert.IsTrue(files.Contains(filename)); // Read the file using (var bytes = fileSystemConnector.GetFileStream(filename, containerWithForwardSlash)) { Assert.IsTrue(byteCount == bytes.Length); } // Delete the file fileSystemConnector.DeleteFile(filename, containerWithForwardSlash); // Folder will be deleted in cleanup }