public void Setup() { _settings = new ApplicationSettings(); _settings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Attachments"); _attachmentPathUtil = new AttachmentPathUtil(_settings); try { // Delete any existing attachments folder // Remove the files 1st if (Directory.Exists(_settings.AttachmentsFolder)) { DirectoryInfo directoryInfo = new DirectoryInfo(_settings.AttachmentsFolder); foreach (FileInfo file in directoryInfo.GetFiles()) { File.Delete(file.FullName); } if (directoryInfo.Exists) { directoryInfo.Attributes = FileAttributes.Normal; directoryInfo.Delete(true); } } Directory.CreateDirectory(_settings.AttachmentsFolder); } catch (IOException e) { Assert.Fail("Unable to delete the attachments folder " + _settings.AttachmentsFolder + ", does it have a lock?" + e.ToString()); } }
private static string[] _filesToExclude = new string[] { "emptyfile.txt", "_installtest.txt" }; // installer/publish files /// <summary> /// Constructor for the file manager. /// </summary> /// <remarks>This action requires editor rights.</remarks> public FileManagerController(ApplicationSettings settings, UserServiceBase userManager, IUserContext context, SettingsService settingsService, AttachmentFileHandler attachment) : base(settings, userManager, context, settingsService) { _attachmentHandler = attachment; _attachmentPathUtil = new AttachmentPathUtil(settings); }
/// <summary> /// This action is for JSON calls only. Checks to see if the provided folder exists and if it can be written to. /// </summary> /// <param name="folder"></param> /// <returns>Returns a <see cref="TestResult"/> containing information about any errors.</returns> public ActionResult TestAttachments(string folder) { if (InstalledAndUserIsNotAdmin()) { return(Content("")); } string errors = AttachmentPathUtil.AttachmentFolderExistsAndWriteable(folder, HttpContext); return(Json(new TestResult(errors), JsonRequestBehavior.AllowGet)); }
public void AttachmentFolderExistsAndWriteable_Should_Return_Error_For_Missing_Folder() { // Arrange string directory = @"c:\87sd9f7dssdds3232"; string expectedMessage = "The directory does not exist, please create it first"; // Act string actualMessage = AttachmentPathUtil.AttachmentFolderExistsAndWriteable(directory, null); // Assert Assert.That(actualMessage, Is.EqualTo(expectedMessage)); }
public void AttachmentFolderExistsAndWriteable_Should_Return_Error_For_Empty_Folder() { // Arrange string directory = ""; string expectedMessage = "The folder name is empty"; // Act string actualMessage = AttachmentPathUtil.AttachmentFolderExistsAndWriteable(directory, null); // Assert Assert.That(actualMessage, Is.EqualTo(expectedMessage)); }
public void AttachmentFolderExistsAndWriteable_Should_Return_Empty_String_For_Writeable_Folder() { // Arrange string directory = AppDomain.CurrentDomain.BaseDirectory; string expectedMessage = ""; // Act string actualMessage = AttachmentPathUtil.AttachmentFolderExistsAndWriteable(directory, null); // Assert Assert.That(actualMessage, Is.EqualTo(expectedMessage)); }
public void attachmentfolderexistsandwriteable_should_return_empty_string_for_writeable_folder() { // Arrange string directory = AppDomain.CurrentDomain.BaseDirectory; string expectedMessage = ""; // Act string actualMessage = AttachmentPathUtil.AttachmentFolderExistsAndWriteable(directory, null); // Assert Assert.That(actualMessage, Is.EqualTo(expectedMessage)); }
private static readonly string[] FilesToExclude = new string[] { "emptyfile.txt", "_installtest.txt" }; // installer/publish files #endregion #region constructors public LocalFileService(ApplicationSettings settings, SettingsService settingsService) { _applicationSettings = settings; _settingsService = settingsService; _attachmentPathUtil = new AttachmentPathUtil(settings); }