本文整理汇总了C#中CredentialCache.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# CredentialCache.GetEnumerator方法的具体用法?C# CredentialCache.GetEnumerator怎么用?C# CredentialCache.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CredentialCache
的用法示例。
在下文中一共展示了CredentialCache.GetEnumerator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEnumerator_MoveNextIndex_Invalid
public static void GetEnumerator_MoveNextIndex_Invalid()
{
CredentialCache cc = new CredentialCache();
IEnumerator enumerator = cc.GetEnumerator();
enumerator.MoveNext();
Assert.Throws<InvalidOperationException>(() => enumerator.Current);
}
示例2: GetEnumerator_CurrentSynchronization_Invalid
public static void GetEnumerator_CurrentSynchronization_Invalid(CredentialCache cc, bool addUri)
{
//An InvalidOperationException is thrown when getting the current enumerated object
//when a credential is added to the cache after getting the enumerator
IEnumerator enumerator = cc.GetEnumerator();
enumerator.MoveNext();
if (addUri)
{
cc.Add(new Uri("http://whatever:80"), authenticationType1, credential1);
}
else
{
cc.Add("whatever", 80, authenticationType1, credential1);
}
Assert.Throws<InvalidOperationException>(() => enumerator.Current);
}
示例3: GetEnumerator_ResetIndexGetCurrent_Invalid
public static void GetEnumerator_ResetIndexGetCurrent_Invalid(CredentialCache cc)
{
IEnumerator enumerator = cc.GetEnumerator();
enumerator.Reset();
Assert.Throws<InvalidOperationException>(() => enumerator.Current);
}
示例4: GetEnumerator_Enumerate_Success
public static void GetEnumerator_Enumerate_Success(CredentialCache cc, int count)
{
IEnumerator enumerator = cc.GetEnumerator();
Assert.NotNull(enumerator);
for (int iterations = 0; iterations < 2; iterations++)
{
Assert.Throws<InvalidOperationException>(() => enumerator.Current);
for (int i = 0; i < count; i++)
{
Assert.True(enumerator.MoveNext());
Assert.NotNull(enumerator.Current);
}
Assert.False(enumerator.MoveNext());
Assert.Throws<InvalidOperationException>(() => enumerator.Current);
enumerator.Reset();
}
}