public GetScheduledResources ( ) : ObservableCollection |
||
Результат | ObservableCollection |
void OnServerChanged(object obj) { var tmpEnv = obj as IEnvironmentModel; if (!DoDeactivate()) { return; } CurrentEnvironment = tmpEnv; if (CurrentEnvironment != null && CurrentEnvironment.AuthorizationService != null && CurrentEnvironment.IsConnected) { if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null)) { ClearConnectionError(); _resourcePicker = new ResourcePickerDialog(enDsfActivityType.Workflow, CurrentEnvironment); ScheduledResourceModel = new ClientScheduledResourceModel(CurrentEnvironment); IsLoading = true; _asyncWorker.Start( () => ScheduledResourceModel.ScheduledResources = ScheduledResourceModel.GetScheduledResources(), () => { foreach (var scheduledResource in ScheduledResourceModel.ScheduledResources) { scheduledResource.NextRunDate = scheduledResource.Trigger.Trigger.StartBoundary; scheduledResource.OldName = scheduledResource.Name; } NotifyOfPropertyChange(() => TaskList); if (TaskList.Count > 0) { SelectedTask = TaskList[0]; } IsLoading = false; }); } else { SetConnectionError(); ClearViewModel(); } } else { ClearConnectionError(); ClearViewModel(); } }
public void ClientScheduledResourceModel_GetScheduledResources_ReturnsCollectionOfIScheduledResource() { //------------Setup for test-------------------------- var resources = new ObservableCollection<IScheduledResource>(); var scheduledResourceForTest = new ScheduledResourceForTest(); resources.Add(scheduledResourceForTest); Dev2JsonSerializer serializer = new Dev2JsonSerializer(); var serializeObject = serializer.SerializeToBuilder(resources); var mockEnvironmentModel = new Mock<IEnvironmentModel>(); var mockConnection = new Mock<IEnvironmentConnection>(); mockConnection.Setup(connection => connection.IsConnected).Returns(true); mockConnection.Setup(connection => connection.ExecuteCommand(It.IsAny<StringBuilder>(), It.IsAny<Guid>(), It.IsAny<Guid>())).Returns(serializeObject); mockConnection.Setup(connection => connection.WorkspaceID).Returns(Guid.NewGuid()); mockEnvironmentModel.Setup(model => model.Connection).Returns(mockConnection.Object); var clientScheduledResourceModel = new ClientScheduledResourceModel(mockEnvironmentModel.Object); //------------Execute Test--------------------------- var scheduledResources = clientScheduledResourceModel.GetScheduledResources(); //------------Assert Results------------------------- Assert.AreEqual(1, scheduledResources.Count); }
void OnServerChanged(object obj) { var tmpEnv = obj as IEnvironmentModel; if(!DoDeactivate()) { return; } CurrentEnvironment = tmpEnv; if(CurrentEnvironment != null && CurrentEnvironment.AuthorizationService != null && CurrentEnvironment.IsConnected) { if(CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null)) { ClearConnectionError(); _resourcePicker = new ResourcePickerDialog(enDsfActivityType.Workflow, CurrentEnvironment); ScheduledResourceModel = new ClientScheduledResourceModel(CurrentEnvironment); IsLoading = true; _asyncWorker.Start( () => ScheduledResourceModel.ScheduledResources = ScheduledResourceModel.GetScheduledResources(), () => { foreach(var scheduledResource in ScheduledResourceModel.ScheduledResources) { scheduledResource.NextRunDate = scheduledResource.Trigger.Trigger.StartBoundary; scheduledResource.OldName = scheduledResource.Name; } NotifyOfPropertyChange(() => TaskList); if(TaskList.Count > 0) { SelectedTask = TaskList[0]; } IsLoading = false; }); } else { SetConnectionError(); ClearViewModel(); } } else { ClearConnectionError(); ClearViewModel(); } }