Skip to content

Commit

Permalink
Fix broken unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyhfish authored and bdukes committed Mar 26, 2020
1 parent 2aab772 commit aaeff3d
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Portals.Internal;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.Cache;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Social.Messaging.Data;
using DotNetNuke.Services.Social.Messaging;
Expand Down Expand Up @@ -49,6 +51,9 @@ public class MessagingControllerTests
private Mock<RoleProvider> _mockRoleProvider;
private Mock<CachingProvider> _mockCacheProvider;
private Mock<ILocalizationProvider> _mockLocalizationProvider;
private Mock<IFolderManager> _folderManager;
private Mock<IFileManager> _fileManager;
private Mock<IFolderPermissionController> _folderPermissionController;

private DataTable _dtMessages;
private DataTable _dtMessageAttachment;
Expand Down Expand Up @@ -91,12 +96,21 @@ public void SetUp()

DataService.RegisterInstance(_mockDataService.Object);

_folderManager = new Mock<IFolderManager>();
_fileManager = new Mock<IFileManager>();
_folderPermissionController = new Mock<IFolderPermissionController>();

FolderManager.RegisterInstance(_folderManager.Object);
FileManager.RegisterInstance(_fileManager.Object);
FolderPermissionController.SetTestableInstance(_folderPermissionController.Object);

SetupDataProvider();
SetupRoleProvider();
SetupDataTables();
SetupUsers();
SetupPortalSettings();
SetupCachingProvider();
SetupFileControllers();

_mockInternalMessagingController.Setup(m => m.GetLastSentMessage(It.IsAny<UserInfo>())).Returns((Message)null);
}
Expand Down Expand Up @@ -178,6 +192,13 @@ private void SetupRoleProvider()
_mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == Constants.UserID_FirstSocialGroupOwner), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { userFirstSocialGroupOwner });
}

private void SetupFileControllers()
{
_folderManager.Setup(f => f.GetFolder(It.IsAny<int>())).Returns(new FolderInfo());
_fileManager.Setup(f => f.GetFile(It.IsAny<int>())).Returns(new FileInfo());
_folderPermissionController.Setup(f => f.CanViewFolder(It.IsAny<IFolderInfo>())).Returns(true);
}

#endregion

#region Constructor Tests
Expand Down Expand Up @@ -768,6 +789,8 @@ public void MessagingController_CreateMessage_Calls_DataService_SaveSocialMessag
[Test]
public void MessagingController_CreateMessage_Calls_DataService_CreateSocialMessageRecipientsForRole_On_Passing_Role_ByAdmin()
{
InternalMessagingController.SetTestableInstance(_mockInternalMessagingController.Object);

//Arrange
var message = new Message { Subject = "subject", Body = "body" };
var role = new RoleInfo { RoleName = Constants.RoleName_RegisteredUsers, RoleID = Constants.RoleID_RegisteredUsers };
Expand Down

0 comments on commit aaeff3d

Please sign in to comment.