public AddServerNode ( IExplorerItemModel explorerItem ) : void | ||
explorerItem | IExplorerItemModel | |
Результат | void |
public void StudioResourceRepository_AddServerNode_Existing_ItemExpandedAndSelected() { //------------Setup for test-------------------------- Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); var connection = new Mock<IEnvironmentConnection>(); var mockEnvironmentModel = new Mock<IEnvironmentModel>(); mockEnvironmentModel.Setup(e => e.Connection).Returns(connection.Object); mockEnvironmentModel.Setup(a => a.AuthorizationService).Returns(new Mock<IAuthorizationService>().Object); var environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List<IResourceModel>()).Object; var serverItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = ResourceType.Server, EnvironmentId = environmentModel.ID, ResourcePath = "", ResourceId = Guid.NewGuid() }; ExplorerItemModel workflowsFolder = new ExplorerItemModel { DisplayName = "WORKFLOWS", ResourceType = ResourceType.Folder, ResourcePath = "WORKFLOWS", EnvironmentId = mockEnvironmentModel.Object.ID, ResourceId = Guid.NewGuid() }; serverItemModel.Children.Add(workflowsFolder); var studioResourceRepository = new StudioResourceRepository(serverItemModel, _invoke); resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName); TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel); new EnvironmentRepository(testEnvironmentRespository); IEnvironmentModel internalEnvironmentModel = environmentModel; studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID; ExplorerItemModel serverExplorerItem = new ExplorerItemModel(studioResourceRepository, AsyncWorkerTests.CreateSynchronousAsyncWorker().Object, new Mock<IConnectControlSingleton>().Object) { EnvironmentId = Guid.NewGuid(), ResourceType = ResourceType.Server }; studioResourceRepository.AddServerNode(serverExplorerItem); //------------Execute Test--------------------------- studioResourceRepository.AddServerNode(serverExplorerItem); //------------Assert Results------------------------- Assert.AreEqual(2, studioResourceRepository.ExplorerItemModels.Count); Assert.IsTrue(studioResourceRepository.ExplorerItemModels[1].IsExplorerSelected); Assert.IsTrue(studioResourceRepository.ExplorerItemModels[1].IsExplorerExpanded); }