本文整理汇总了C#中Dev2.Explorer.ServerExplorerItem类的典型用法代码示例。如果您正苦于以下问题:C# ServerExplorerItem类的具体用法?C# ServerExplorerItem怎么用?C# ServerExplorerItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerExplorerItem类属于Dev2.Explorer命名空间,在下文中一共展示了ServerExplorerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServerExplorerItem_GetHashCode_ExpectHashCodeSameAsID
public void ServerExplorerItem_GetHashCode_ExpectHashCodeSameAsID()
{
//------------Setup for test--------------------------
var guid = Guid.NewGuid();
const string name = "a";
const ResourceType explorerItemType = ResourceType.PluginService;
var children = new List<IExplorerItem>();
const Permissions permissions = Permissions.DeployFrom;
//------------Execute Test---------------------------
var serverExplorerItem = new ServerExplorerItem(name, guid, explorerItemType, children, permissions, "");
//------------Assert Results-------------------------
Assert.AreEqual(guid.GetHashCode(), serverExplorerItem.GetHashCode());
}
示例2: FetchExplorerItems_Execute_ExpectName
public void FetchExplorerItems_Execute_ExpectName()
{
//------------Setup for test--------------------------
var fetchExplorerItems = new FetchExplorerItems();
ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
var repo = new Mock<IExplorerServerResourceRepository>();
var ws = new Mock<IWorkspace>();
repo.Setup(a => a.Load(It.IsAny<Guid>())).Returns(item).Verifiable();
var serializer = new Dev2JsonSerializer();
ws.Setup(a => a.ID).Returns(Guid.Empty);
fetchExplorerItems.ServerExplorerRepo = repo.Object;
//------------Execute Test---------------------------
var ax = fetchExplorerItems.Execute(new Dictionary<string, StringBuilder>(), ws.Object);
//------------Assert Results-------------------------
repo.Verify(a => a.Load(It.IsAny<Guid>()));
Assert.AreEqual(serializer.Deserialize<IExplorerItem>(ax.ToString()).ResourceId, item.ResourceId);
}
示例3: GetVersions_Execute_ExpectName
public void GetVersions_Execute_ExpectName()
{
//------------Setup for test--------------------------
var getVersions = new GetVersions();
var resourceId = Guid.NewGuid();
ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
var repo = new Mock<IServerVersionRepository>();
var ws = new Mock<IWorkspace>();
repo.Setup(a => a.GetVersions(resourceId)).Returns(new List<IExplorerItem> {item});
var serializer = new Dev2JsonSerializer();
ws.Setup(a => a.ID).Returns(Guid.Empty);
getVersions.ServerVersionRepo = repo.Object;
//------------Execute Test---------------------------
var ax = getVersions.Execute(new Dictionary<string, StringBuilder> {{"resourceId",new StringBuilder( resourceId.ToString())}}, ws.Object);
//------------Assert Results-------------------------
repo.Verify(a => a.GetVersions(It.IsAny<Guid>()));
Assert.AreEqual(serializer.Deserialize<IList<IExplorerItem>>(ax.ToString())[0].ResourceId, item.ResourceId);
}
示例4: ServerExplorerItem_Constructor_Construct_ExpectAllFieldsAreSetup
public void ServerExplorerItem_Constructor_Construct_ExpectAllFieldsAreSetup()
{
//------------Setup for test--------------------------
var guid = Guid.NewGuid();
const string name = "a";
const ResourceType explorerItemType = ResourceType.Folder;
var children = new List<IExplorerItem>();
const Permissions permissions = Permissions.DeployFrom;
//------------Execute Test---------------------------
var serverExplorerItem = new ServerExplorerItem(name, guid, explorerItemType, children, permissions, "/");
//------------Assert Results-------------------------
Assert.AreEqual(children, serverExplorerItem.Children);
Assert.AreEqual(name, serverExplorerItem.DisplayName);
Assert.AreEqual(serverExplorerItem.ResourceType, explorerItemType);
Assert.AreEqual(permissions, serverExplorerItem.Permissions);
Assert.AreEqual(guid, serverExplorerItem.ResourceId);
}
示例5: CreateFolder_Execute_ExpectCreateCalled
public void CreateFolder_Execute_ExpectCreateCalled()
{
//------------Setup for test--------------------------
var createFolderService = new AddFolderService();
ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
var repo = new Mock<IExplorerServerResourceRepository>();
var ws = new Mock<IWorkspace>();
repo.Setup(a => a.AddItem(item, It.IsAny<Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Fail, "noddy"));
var serializer = new Dev2JsonSerializer();
var inputs = new Dictionary<string, StringBuilder>();
inputs.Add("itemToAdd", serializer.SerializeToBuilder(item));
ws.Setup(a => a.ID).Returns(Guid.Empty);
createFolderService.ServerExplorerRepo = repo.Object;
//------------Execute Test---------------------------
createFolderService.Execute(inputs, ws.Object);
//------------Assert Results-------------------------
repo.Verify(a => a.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()));
}
示例6: ServerExplorerItem_Equals_ExpectEqualityOnGuidOnly
public void ServerExplorerItem_Equals_ExpectEqualityOnGuidOnly()
{
//------------Setup for test--------------------------
var guid = Guid.NewGuid();
const string name = "a";
const ResourceType explorerItemType = ResourceType.PluginService;
var children = new List<IExplorerItem>();
const Permissions permissions = Permissions.DeployFrom;
//------------Execute Test---------------------------
var serverExplorerItem = new ServerExplorerItem(name, guid, explorerItemType, children, permissions, "");
var serverExplorerItem2 = new ServerExplorerItem(name, guid, explorerItemType, children, Permissions.Administrator, "");
var serverExplorerItem3 = new ServerExplorerItem(name, Guid.NewGuid(), explorerItemType, children, permissions, "");
//------------Assert Results-------------------------
Assert.AreEqual(serverExplorerItem, serverExplorerItem2);
Assert.AreNotEqual(serverExplorerItem, null);
Assert.AreEqual(serverExplorerItem, serverExplorerItem);
Assert.AreNotEqual(serverExplorerItem, guid);
Assert.AreNotEqual(serverExplorerItem, serverExplorerItem3);
}
示例7: StudioResourceRepository_HideHistory_ClearsChildren
public void StudioResourceRepository_HideHistory_ClearsChildren()
{
//------------Setup for test--------------------------
var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
var mockVersionRepository = new Mock<IVersionRepository>();
var superWFId = Guid.NewGuid();
var parent = new ServerExplorerItem
{
ResourceType = ResourceType.WorkflowService,
DisplayName = "SuperWF",
ResourceId = superWFId,
Permissions = Permissions.Contribute,
ResourcePath = "MANFOLDER\\APRIL WORK\\SUB FOLDER",
Children = new List<IExplorerItem>
{
new ServerExplorerItem{ ResourceType = ResourceType.WebService, DisplayName = "v2 2012-10-10 Save", ResourceId = Guid.NewGuid(), Permissions = Permissions.View },
new ServerExplorerItem{ ResourceType = ResourceType.WebService, DisplayName = "v2 2012-10-10 Save", ResourceId = Guid.NewGuid(), Permissions = Permissions.View }
}
};
SetupEnvironmentRepo(Guid.Empty);
var repo = new StudioResourceRepository(parent, Guid.Empty, _invoke)
{
GetVersionProxy = id => mockVersionRepository.Object,
GetExplorerProxy = id => mockExplorerResourceRepository.Object,
GetCurrentEnvironment = () => Guid.Empty
};
//------------Execute Test---------------------------
repo.HideVersionHistory(Guid.Empty, superWFId);
//------------Assert Results-------------------------
var actual = repo.FindItemById(superWFId);
Assert.AreEqual(0, actual.Children.Count);
}
示例8: StudioResourceRepository_GetEnvironmentModel_HasMatchingID_ReturnsTrue
public void StudioResourceRepository_GetEnvironmentModel_HasMatchingID_ReturnsTrue()
{
//------------Setup for test--------------------------
var environmentModel = new Mock<IEnvironmentModel>();
var environmentId = Guid.NewGuid();
environmentModel.Setup(model => model.ID).Returns(environmentId);
var mockConnection = new Mock<IEnvironmentConnection>();
mockConnection.Setup(connection => connection.WebServerUri).Returns(new Uri("http://bob:3142/"));
var serverID = Guid.NewGuid();
mockConnection.Setup(connection => connection.ServerID).Returns(serverID);
environmentModel.Setup(a => a.Connection).Returns(mockConnection.Object);
ServerExplorerItem serverExplorerItem = new ServerExplorerItem { WebserverUri = "http://bob:3142/", ServerId = serverID };
//------------Execute Test---------------------------
var found = StudioResourceRepository.GetEnvironmentModel(environmentModel.Object, serverExplorerItem, environmentId);
//------------Assert Results-------------------------
Assert.IsTrue(found);
}
示例9: StudioResourceRepository_ShowVersionHistory_NoItemsReturned_InfoItemAttachedToParent
public void StudioResourceRepository_ShowVersionHistory_NoItemsReturned_InfoItemAttachedToParent()
{
//------------Setup for test--------------------------
var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
var mockVersionRepository = new Mock<IVersionRepository>();
mockVersionRepository.Setup(m => m.GetVersions(It.IsAny<Guid>())).Returns(new List<IExplorerItem>());
var superWFId = Guid.NewGuid();
var parent = new ServerExplorerItem
{
ResourceType = ResourceType.WorkflowService,
DisplayName = "SuperWF",
ResourceId = superWFId,
Permissions = Permissions.Contribute,
ResourcePath = "MANFOLDER\\APRIL WORK\\SUB FOLDER"
};
SetupEnvironmentRepo(Guid.Empty);
var repo = new StudioResourceRepository(parent, Guid.Empty, _invoke)
{
GetVersionProxy = id => mockVersionRepository.Object,
GetExplorerProxy = id => mockExplorerResourceRepository.Object,
GetCurrentEnvironment = () => Guid.Empty
};
//------------Execute Test---------------------------
repo.ShowVersionHistory(Guid.Empty, superWFId);
//------------Assert Results-------------------------
var actual = repo.FindItemById(superWFId);
Assert.AreEqual(1, actual.Children.Count);
Assert.AreEqual("There is no version history to display", actual.Children[0].DisplayName);
}
示例10: ServerExplorerRepository_RenameFolder_FilesystemError_ExpectFailureMessage
public void ServerExplorerRepository_RenameFolder_FilesystemError_ExpectFailureMessage()
{
//------------Setup for test--------------------------
var catalogue = new Mock<IResourceCatalog>();
ResourceCatalogResult resourceCatalogResult = new ResourceCatalogResult { Status = ExecStatus.Success, Message = "" };
catalogue.Setup(catalog => catalog.RenameCategory(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<string>())).Returns(resourceCatalogResult);
var factory = new Mock<IExplorerItemFactory>();
var dir = new Mock<IDirectory>();
var guid = Guid.NewGuid();
var explorerItem = new ServerExplorerItem(
"dave", guid,
ResourceType.DbSource,
new List<IExplorerItem>()
, Permissions.Administrator, "bob"
);
factory.Setup(a => a.CreateRootExplorerItem(It.IsAny<string>(), It.IsAny<Guid>())).Returns(explorerItem);
dir.Setup(a => a.Exists(It.IsAny<string>())).Returns(true);
dir.Setup(a => a.Delete(It.IsAny<string>(), It.IsAny<bool>())).Throws(new FieldAccessException("bob has an error")).Verifiable();
var sync = new Mock<IExplorerRepositorySync>();
var serverExplorerRepository = new ServerExplorerRepository(catalogue.Object, factory.Object, dir.Object, sync.Object, new Mock<IServerVersionRepository>().Object, new FileWrapper());
//------------Execute Test---------------------------
var result = serverExplorerRepository.RenameFolder("monkey", "moocowimpi", Guid.NewGuid());
//------------Assert Results-------------------------
Assert.AreEqual(result.Message, "bob has an error");
Assert.AreEqual(result.Status, ExecStatus.AccessViolation);
}
示例11: BuildStructureFromFilePath
private IList<IExplorerItem> BuildStructureFromFilePath(IDirectory directory, string path, string rootPath)
{
var firstGen =
directory.GetDirectories(path)
.Where(a => !a.EndsWith("VersionControl"));
IList<IExplorerItem> children = new List<IExplorerItem>();
foreach(var resource in firstGen)
{
var resourcePath = resource.Replace(rootPath, "").Substring(1);
var node = new ServerExplorerItem(new DirectoryInfo(resource).Name, Guid.NewGuid(), ResourceType.Folder, null, _authService.GetResourcePermissions(Guid.Empty), resourcePath);
children.Add(node);
node.Children = BuildStructureFromFilePath(directory, resource, rootPath);
}
return children;
}
示例12: StudioResourceRepository_GetVersion_VersionIsNull_ThrowsException
public void StudioResourceRepository_GetVersion_VersionIsNull_ThrowsException()
{
//------------Setup for test--------------------------
var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
var mockVersionRepository = new Mock<IVersionRepository>();
var parent = new ServerExplorerItem
{
ResourceType = ResourceType.WorkflowService,
DisplayName = "SuperWF",
ResourceId = Guid.NewGuid(),
Permissions = Permissions.Contribute,
ResourcePath = "MANFOLDER\\APRIL WORK\\SUB FOLDER"
};
var repo = new StudioResourceRepository(parent, Guid.Empty, _invoke)
{
GetVersionProxy = id => mockVersionRepository.Object,
GetExplorerProxy = id => mockExplorerResourceRepository.Object,
GetCurrentEnvironment = () => Guid.Empty
};
//------------Execute Test---------------------------
repo.GetVersion(null, Guid.Empty);
}
示例13: GetTestData
private IExplorerItem GetTestData(string workFlowId = "DF279411-F678-4FCC-BE88-A1B613EE51E3",
string dbServiceId = "DF279411-F678-4FCC-BE88-A1B613EE51E3", Guid? folderID = null)
{
var workflow1 = new ServerExplorerItem
{
ResourceType = ResourceType.WorkflowService,
DisplayName = "workflow1",
ResourceId = string.IsNullOrEmpty(workFlowId) ? Guid.NewGuid() : Guid.Parse(workFlowId),
Permissions = Permissions.Administrator
};
var dbService1 = new ServerExplorerItem { ResourceType = ResourceType.DbService, DisplayName = "dbService1", ResourceId = string.IsNullOrEmpty(dbServiceId) ? Guid.NewGuid() : Guid.Parse(dbServiceId), Permissions = Permissions.Contribute };
var webService1 = new ServerExplorerItem { ResourceType = ResourceType.WebService, DisplayName = "webService1", ResourceId = Guid.NewGuid(), Permissions = Permissions.View };
var pluginService1 = new ServerExplorerItem { ResourceType = ResourceType.PluginService, DisplayName = "pluginService1", ResourceId = Guid.NewGuid(), Permissions = Permissions.View };
var dbSource1 = new ServerExplorerItem { ResourceType = ResourceType.DbSource, DisplayName = "dbSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var webSource1 = new ServerExplorerItem { ResourceType = ResourceType.WebSource, DisplayName = "webSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var pluginSource1 = new ServerExplorerItem { ResourceType = ResourceType.PluginSource, DisplayName = "pluginSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var emailSource1 = new ServerExplorerItem { ResourceType = ResourceType.EmailSource, DisplayName = "emailSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var serverSource1 = new ServerExplorerItem { ResourceType = ResourceType.ServerSource, DisplayName = "serverSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var folder1 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "folder1", ResourceId = folderID ?? Guid.NewGuid(), Permissions = Permissions.Administrator };
var folder2 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "folder2", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var subfolder1 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "subfolder1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
var localhost = new ServerExplorerItem { ResourceType = ResourceType.Server, DisplayName = "localhost", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator };
dbService1.Parent = webService1.Parent = pluginService1.Parent = subfolder1.Parent = folder1;
dbSource1.Parent = webSource1.Parent = pluginSource1.Parent = emailSource1.Parent = serverSource1.Parent = folder2;
folder2.Children = new List<IExplorerItem>
{
dbSource1,
webSource1,
pluginSource1,
emailSource1,
serverSource1
};
folder1.Children = new List<IExplorerItem>
{
dbService1,
webService1,
pluginService1,
subfolder1
};
localhost.Children = new List<IExplorerItem> { folder1, workflow1 };
workflow1.Parent = localhost;
folder1.Parent = localhost;
return localhost;
}
示例14: MoveItem_Execute_ExpectRename
public void MoveItem_Execute_ExpectRename()
{
//------------Setup for test--------------------------
var MoveItemService = new MoveItemService();
ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
var repo = new Mock<IExplorerServerResourceRepository>();
var ws = new Mock<IWorkspace>();
repo.Setup(a => a.MoveItem(It.IsAny<IExplorerItem>(), It.IsAny<string>(), It.IsAny<Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable();
var serializer = new Dev2JsonSerializer();
var inputs = new Dictionary<string, StringBuilder>
{
{
"itemToMove", serializer.SerializeToBuilder(item)
},
{
"newPath", new StringBuilder("bob")
}
};
ws.Setup(a => a.ID).Returns(Guid.Empty);
MoveItemService.ServerExplorerRepo = repo.Object;
//------------Execute Test---------------------------
MoveItemService.Execute(inputs, ws.Object);
//------------Assert Results-------------------------
repo.Verify(a => a.MoveItem(It.IsAny<IExplorerItem>(), It.IsAny<string>(), It.IsAny<Guid>()));
}
示例15: SetupEnvironmentRepo
public void StudioResourceRepository_ItemAddedMessageHandler_ItemNotFoundInResourceRepo_Workflow_AddedSuccessfully()
{
//------------Setup for test--------------------------
var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
var mockVersionRepository = new Mock<IVersionRepository>();
var parent = new ServerExplorerItem
{
ResourceType = ResourceType.Folder,
DisplayName = "SUB FOLDER",
ResourceId = Guid.NewGuid(),
Permissions = Permissions.Contribute,
ResourcePath = "MANFOLDER\\SUB FOLDER"
};
var mockResourceRepo = SetupEnvironmentRepo(Guid.Empty);
mockResourceRepo.Setup(repository => repository.ReloadResource(It.IsAny<Guid>(), It.Is<Studio.Core.AppResources.Enums.ResourceType>(type => type == Studio.Core.AppResources.Enums.ResourceType.WorkflowService), It.IsAny<IEqualityComparer<IResourceModel>>(), It.IsAny<bool>()));
// ReSharper disable ObjectCreationAsStatement
new StudioResourceRepository(parent, Guid.Empty, _invoke)
// ReSharper restore ObjectCreationAsStatement
{
GetVersionProxy = id => mockVersionRepository.Object,
GetExplorerProxy = id => mockExplorerResourceRepository.Object,
GetCurrentEnvironment = () => Guid.Empty
};
var studioResourceRepository = StudioResourceRepository.Instance;
//------------Execute Test---------------------------
studioResourceRepository.ItemAddedMessageHandler(new ServerExplorerItem
{
DisplayName = "TEST FOLDER",
ResourcePath = "MANFOLDER\\SUB FOLDER\\TEST FOLDER",
ResourceType = ResourceType.WorkflowService
});
//------------Assert Results-------------------------
mockResourceRepo.Verify(repository => repository.ReloadResource(It.IsAny<Guid>(), It.Is<Studio.Core.AppResources.Enums.ResourceType>(type => type == Studio.Core.AppResources.Enums.ResourceType.WorkflowService), It.IsAny<IEqualityComparer<IResourceModel>>(), It.IsAny<bool>()), Times.Once());
}