提供无效的TFS凭证以用于测试目的

时间:2011-12-16 09:54:58

标签: tfs tfs-sdk

我遇到的情况是测试提供无效的TFS凭据以便验证失败。但是,TfsTeamProjectCollection正在获取我自己的凭据,并且始终会成功调用Authenticate()。有没有办法强制无效凭据?这就是我在做的事情:

var account = new NetworkCredential(user.UserName, user.Password, user.Domain);
var provider = new NetworkCredentialsProvider(account);
teamProjectCollection = new TfsTeamProjectCollection(
    new Uri(serverUri),
    provider);
teamProjectCollection.Authenticate(); // should throw with invalid credentials

NetworkCredentialsProvider类只返回其构造函数中提供的NetworkCredential

以前这可以使用TeamFoundationServer类(现已弃用)。

1 个答案:

答案 0 :(得分:3)

以下是我要找的答案:

var account = new NetworkCredential(user.UserName, user.Password, user.Domain);
teamProjectCollection = new TfsTeamProjectCollection(new Uri(serverUri),account);
teamProjectCollection.Authenticate();

对不起噪音!

相关问题