Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FolderManager unit tests #3418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,54 @@ public void AddFolder_Throws_When_Folder_Already_Exists()

}

[Test]
[ExpectedException(typeof(InvalidFolderPathException))]
public void AddFolder_Throws_When_FolderPath_Is_Invalid()
{
// arrange
var folderMapping = new FolderMappingInfo
{
PortalID = Constants.CONTENT_ValidPortalId
};

_mockFolderManager
.Setup(mfm => mfm.FolderExists(It.IsAny<int>(), It.IsAny<string>()))
.Returns(false);

_mockFolderManager
.Setup(mfm => mfm.IsValidFolderPath(It.IsAny<string>()))
.Returns(false);

// act
_mockFolderManager.Object.AddFolder(folderMapping, Constants.FOLDER_ValidSubFolderRelativePath);

// assert (implicit)
}

[Test]
public void IsValidFolderPath_Returns_True_When_FolderPath_Is_Valid()
{
// arrange (implicit)

// act
var result = _mockFolderManager.Object.IsValidFolderPath(Constants.FOLDER_ValidSubFolderRelativePath);

// assert
Assert.IsTrue(result);
}

[Test]
public void IsValidFolderPath_Returns_False_When_FolderPath_Is_Invalid()
{
// arrange (implicit)

// act
var result = _mockFolderManager.Object.IsValidFolderPath(Constants.FOLDER_InvalidSubFolderRelativePath);

// assert
Assert.IsFalse(result);
}

#endregion

#region DeleteFolder
Expand Down
1 change: 1 addition & 0 deletions DNN Platform/Tests/DotNetNuke.Tests.Utilities/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public class Constants
public const string FOLDER_ValidSubFolderName = "subfolder";
public const string FOLDER_ValidSubFolderPath = "C:\\folder\\subfolder";
public const string FOLDER_ValidSubFolderRelativePath = "folder/subfolder/";
public const string FOLDER_InvalidSubFolderRelativePath = "folder/subfolder/../";
public const string FOLDER_ValidUNCFolderPath = @"\\SERVER\folder";
public const string FOLDER_ValidUNCSubFolderPath = @"\\SERVER\folder\subfolder";
public const string FOLDER_ValidZipFileName = "file.zip";
Expand Down