/// <inheritdoc/> public async Task ConfigureAsync(TfsServiceProviderConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (configuration.Username.Equals("invalidUsername") || configuration.Password.Equals("invalidPassword")) { throw new TeamFoundationServerUnauthorizedException(); } await Task.Run( () => { if (this.workItems.Any(w => w.Id == configuration.ParentWorkItemId)) { this.parentWorkItemId = configuration.ParentWorkItemId; } else { throw new DeniedOrNotExistException(); } }); }
[Ignore] // toso: Remove this when we move to rest api public void TfsServiceProviderConfigureThrowsIfAuthenticationFails() { var invalidCredentialConfig = new TfsServiceProviderConfiguration("invalidUsername", "invalidPassword"); invalidCredentialConfig.ParentWorkItemId = this.tfsServiceProviderDefaultConfig.ParentWorkItemId; invalidCredentialConfig.WorkItemType = "Task"; Func <Task> action = async() => await this.tfsServiceProvider.ConfigureAsync(invalidCredentialConfig); action.ShouldThrow <TeamFoundationServerUnauthorizedException>(); }
/// <summary> /// Initializes a new instance of the <see cref="TfsSink"/> class. /// </summary> /// <param name="tfsServiceProvider"> /// Service endpoint. /// </param> /// <param name="credential"> /// The credential. /// </param> /// <param name="parentWorkItem"> /// Parent work item id for all tasks. /// </param> /// <param name="fieldMap">Map of work item fields to mail properties.</param> protected TfsSink(ITfsServiceProvider tfsServiceProvider, NetworkCredential credential, int parentWorkItem, string workItemType, IDictionary <string, object> fieldMap) { if (credential == null) { throw new ArgumentNullException(nameof(credential)); } if (fieldMap == null) { throw new ArgumentNullException(nameof(fieldMap)); } this.logger = Log.Logger.ForContext <TfsSink>(); this.tfsServiceProvider = tfsServiceProvider; this.fieldMap = fieldMap; this.tfsServiceProviderConfiguration = new TfsServiceProviderConfiguration(credential.UserName, credential.Password) { ParentWorkItemId = parentWorkItem, WorkItemType = string.IsNullOrEmpty(workItemType) ? "Task" : workItemType }; }
public void InitializeTest() { // Reset the connection state at start of test this.tfsServiceProvider = this.CreateTfsServiceProvider(); this.tfsServiceProviderDefaultConfig = this.CreateDefaultConfiguration(); }