fix tests/shared documents
This commit is contained in:
parent
9baa44e2cd
commit
cc1774c121
@ -52,10 +52,9 @@ namespace ASC.Files.Tests
|
||||
SecurityContext = TestServer.Services.GetService<SecurityContext>();
|
||||
UserOptions = TestServer.Services.GetService<IOptions<UserOptions>>().Value;
|
||||
CurrentTenant = SetAndGetCurrentTenant();
|
||||
User = GetUser();
|
||||
Account = GetAccount();
|
||||
//User = GetUser();
|
||||
|
||||
SecurityContext.AuthenticateMe(Account);
|
||||
SecurityContext.AuthenticateMe(CurrentTenant.OwnerId);
|
||||
}
|
||||
|
||||
private void Configure(WebHostBuilderContext hostingContext, IConfigurationBuilder config)
|
||||
@ -100,11 +99,7 @@ namespace ASC.Files.Tests
|
||||
return user;
|
||||
}
|
||||
|
||||
private IAccount GetAccount()
|
||||
{
|
||||
return new Account(CurrentTenant.OwnerId, "di.vahomik22@gmail.com", true);
|
||||
}
|
||||
|
||||
|
||||
public BatchModel GetBatchModel(string text)
|
||||
{
|
||||
var json = text;
|
||||
|
@ -3,6 +3,7 @@ using ASC.Files.Core;
|
||||
using ASC.Files.Tests.Infrastructure;
|
||||
using ASC.Web.Files.Services.WCFService.FileOperations;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
namespace ASC.Files.Tests
|
||||
{
|
||||
@ -15,17 +16,28 @@ namespace ASC.Files.Tests
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetCreateFolderItems))]
|
||||
[Category("section 'My Documents'")]
|
||||
public void CreateFolderReturnsFolderWrapperTest(string folderTitle)
|
||||
{
|
||||
|
||||
var folderWrapper = FilesControllerHelper.CreateFolder(GlobalFolderHelper.FolderMy, folderTitle);
|
||||
Assert.IsNotNull(folderWrapper);
|
||||
Assert.AreEqual(folderTitle, folderWrapper.Title);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetCreateFolderItems))]
|
||||
[Category("section 'Shared Documents'")]
|
||||
public void CreateSharedFolderReturnsFolderWrapperTest(string folderTitle)
|
||||
{
|
||||
const string exception = "You don't have enough permission to create";
|
||||
try
|
||||
{
|
||||
var folderWrapper = FilesControllerHelper.CreateFolder(GlobalFolderHelper.FolderShare, folderTitle);
|
||||
Assert.Fail(exception, folderWrapper.Title);
|
||||
}
|
||||
catch(Exception ex){ Assert.AreEqual(exception, ex.Message); }
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetFolderItems))]
|
||||
[Category("section 'My Documents'")]
|
||||
public void GetFolderReturnsFolderContentWrapperTest(int folderId, bool withSubFolders,int filesCountExpected,int foldersCountExpected)
|
||||
@ -63,6 +75,22 @@ namespace ASC.Files.Tests
|
||||
Assert.AreEqual(folderTitle, folderWrapper.Title);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetRenameFolderItems))]
|
||||
[Category("section 'Shared Documents'")]
|
||||
public void RenameSharedFolderReturnsFolderWrapperTest(int folderId, string folderTitle)
|
||||
{
|
||||
const string exception = "You don't have enough permission to rename the folder";
|
||||
try
|
||||
{
|
||||
var folderWrapper = FilesControllerHelper.RenameFolder(folderId, folderTitle);
|
||||
Assert.Fail(exception, folderWrapper.Title);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Assert.AreEqual(exception, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetDeleteFolderItems))]
|
||||
[Category("section 'My Documents'")]
|
||||
public void DeleteFolderTest(int folderId, bool deleteAfter, bool immediately)
|
||||
@ -86,16 +114,55 @@ namespace ASC.Files.Tests
|
||||
Assert.AreEqual(statusDelete, status.OperationType);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetDeleteFolderItems))]
|
||||
[Category("section 'Shared Documents'")]
|
||||
public void DeleteSharedFolderTest(int folderId, bool deleteAfter, bool immediately)
|
||||
{
|
||||
|
||||
var statuses = FilesControllerHelper.DeleteFolder(
|
||||
folderId,
|
||||
deleteAfter,
|
||||
immediately);
|
||||
|
||||
FileOperationWraper status = null;
|
||||
foreach (var item in statuses)
|
||||
{
|
||||
if (item.OperationType == FileOperationType.Delete)
|
||||
{
|
||||
status = item;
|
||||
}
|
||||
}
|
||||
|
||||
var statusDelete = FileOperationType.Delete;
|
||||
|
||||
Assert.IsNotNull(status);
|
||||
Assert.AreEqual(statusDelete, status.OperationType);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetCreateFileItems))]
|
||||
[Category("section 'My Documents'")]
|
||||
public void CreateFileReturnsFileWrapperTest(string fileTitle)
|
||||
{
|
||||
var fileWrapper = FilesControllerHelper.CreateFile(54, fileTitle);
|
||||
var fileWrapper = FilesControllerHelper.CreateFile(GlobalFolderHelper.FolderMy, fileTitle);
|
||||
|
||||
Assert.IsNotNull(fileWrapper);
|
||||
Assert.AreEqual(fileTitle, fileWrapper.Title);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetCreateFileItems))]
|
||||
[Category("section 'Shared Documents'")]
|
||||
public void CreateSharedFileReturnsFileWrapperTest(string fileTitle)
|
||||
{
|
||||
const string exception = "You don't have enough permission to create";
|
||||
try
|
||||
{
|
||||
var fileWrapper = FilesControllerHelper.CreateFile(GlobalFolderHelper.FolderShare, fileTitle);
|
||||
Assert.Fail(exception, fileWrapper.Title);
|
||||
}
|
||||
catch (Exception ex) { Assert.AreEqual(exception, ex.Message); }
|
||||
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DocumentData), nameof(DocumentData.GetFileInfoItems))]
|
||||
[Category("section 'My Documents'")]
|
||||
public void GetFileInfoReturnsFilesWrapperTest(int fileId, string fileTitleExpected)
|
||||
|
@ -18,12 +18,12 @@ namespace ASC.Files.Tests
|
||||
|
||||
public static IEnumerable<TestCaseData> GetFolderInfoItems()
|
||||
{
|
||||
yield return new TestCaseData(1, "FolderOne");
|
||||
yield return new TestCaseData(34, "FolderTwo");
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetRenameFolderItems()
|
||||
{
|
||||
yield return new TestCaseData(1, "FoldTest");
|
||||
yield return new TestCaseData(23, "FoldTest");
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetDeleteFolderItems()
|
||||
@ -33,18 +33,18 @@ namespace ASC.Files.Tests
|
||||
|
||||
public static IEnumerable<TestCaseData> GetCreateFileItems()
|
||||
{
|
||||
yield return new TestCaseData("FileOne.docx");
|
||||
yield return new TestCaseData("FileTwo.docx");
|
||||
yield return new TestCaseData("FileOne.docs");
|
||||
yield return new TestCaseData("FileTwo.docs");
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetFileInfoItems()
|
||||
{
|
||||
yield return new TestCaseData(1, "FileOne.docx");
|
||||
yield return new TestCaseData(1, "FileTest.mp3");
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetUpdateFileItems()
|
||||
{
|
||||
yield return new TestCaseData(1, "FileTest", 3);
|
||||
yield return new TestCaseData(1, "FileTest.mp3", 3);
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetDeleteFileItems()
|
||||
|
Loading…
Reference in New Issue
Block a user