public void ClientConfiguration() { ITaskProcessorClientConfiguration configuration = AppConfigConfigurationUnitTests.GetClientConfiguration("Client"); Assert.IsNull(configuration.GetPollingQueueKey(typeof(FakeTask))); Assert.AreEqual("Demo", configuration.GetPollingQueueKey(typeof(FakePollingQueueTask))); }
/// <summary> /// Checks if tasks of a specified type are defined in configuration. /// </summary> /// <typeparam name="TTask">The type of the tasks.</typeparam> /// <param name="configuration">The client configuration.</param> /// <returns>True if tasks of the specified tasks are defined in configuration; otherwise false.</returns> public static bool IsSupported <TTask>(this ITaskProcessorClientConfiguration configuration) where TTask : ITask { try { configuration.GetPollingQueueKey(typeof(TTask)); } catch (ArgumentException) { return(false); } return(true); }
private void OnWindowLoaded(object sender, RoutedEventArgs e) { if (this.DataContext == null) { this.DataContext = RadoslavServiceLocator.DefaultInstance.ResolveSingle <MainViewModel>(); ITaskProcessorConfigurationProvider configProvider = RadoslavServiceLocator.DefaultInstance.ResolveSingle <ITaskProcessorConfigurationProvider>(); ITaskProcessorClientConfiguration config = configProvider.GetClientConfiguration(); btnSubmitDemoTask.Visibility = config.IsSupported <DemoTask>() ? Visibility.Visible : Visibility.Collapsed; btnPollingQueueTasks.Visibility = config.IsSupported <DemoPollingQueueTask>() ? Visibility.Visible : Visibility.Collapsed; btnScheduleTask.Visibility = btnPollingQueueTasks.Visibility; } }
/// <summary> /// Initializes a new instance of the <see cref="TaskProcessorFacade"/> class. /// </summary> /// <param name="repository">The repository to use.</param> /// <param name="messageBus">The message bus to use.</param> /// <param name="dateTimeProvider">The date time provider to use.</param> /// <param name="appConfigConfigurationProvider">The configuration provider to read from App.config.</param> /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/>, /// <paramref name="dateTimeProvider"/> or <paramref name="appConfigConfigurationProvider"/> is null.</exception> public TaskProcessorFacade( ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, IDateTimeProvider dateTimeProvider, ITaskProcessorConfigurationProvider appConfigConfigurationProvider) { Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName)); if (repository == null) { throw new ArgumentNullException("repository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (dateTimeProvider == null) { throw new ArgumentNullException("dateTimeProvider"); } if (appConfigConfigurationProvider == null) { throw new ArgumentNullException("appConfigConfigurationProvider"); } this.repository = repository; this.messageBus = messageBus; this.dateTimeProvider = dateTimeProvider; this.configuration = appConfigConfigurationProvider.GetClientConfiguration(); Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName)); }
public void ClientConfigurationGetPollingQueueKeyTaskTypeNotFound() { ITaskProcessorClientConfiguration config = AppConfigConfigurationUnitTests.GetClientConfiguration("Empty"); config.GetPollingQueueKey(typeof(FakeTask)); }
public void ClientConfigurationGetPollingQueueKeyInvalidTaskType() { ITaskProcessorClientConfiguration config = AppConfigConfigurationUnitTests.GetClientConfiguration("Client"); config.GetPollingQueueKey(typeof(ITimer)); }
public void ClientConfigurationGetPollingQueueKeyNullTaskType() { ITaskProcessorClientConfiguration config = AppConfigConfigurationUnitTests.GetClientConfiguration("Client"); config.GetPollingQueueKey(null); }