本文整理汇总了C#中DiagnosticBag.Count方法的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticBag.Count方法的具体用法?C# DiagnosticBag.Count怎么用?C# DiagnosticBag.Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiagnosticBag
的用法示例。
在下文中一共展示了DiagnosticBag.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiagnosticBag
public void DiagnosticBag()
{
DiagnosticBag bag1 = new DiagnosticBag();
bag1.Add(CreateDiagnostic(4));
bag1.Add(CreateDiagnostic(7));
Assert.False(bag1.IsEmpty);
Assert.Equal(2, bag1.Count());
Assert.NotNull(bag1.ToString());
bool found4 = false, found7 = false;
foreach (Diagnostic d in bag1)
{
if (d.Code == 4)
{
Assert.False(found4);
found4 = true;
}
else if (d.Code == 7)
{
Assert.False(found7);
found7 = true;
}
else
Assert.True(false);
}
DiagnosticBag bag2 = new DiagnosticBag();
bag1.Add(bag2);
Assert.False(bag1.IsEmpty);
Assert.Equal(2, bag1.Count());
found4 = false; found7 = false;
foreach (Diagnostic d in bag1)
{
if (d.Code == 4)
{
Assert.False(found4);
found4 = true;
}
else if (d.Code == 7)
{
Assert.False(found7);
found7 = true;
}
else
Assert.True(false);
}
DiagnosticBag bag3 = new DiagnosticBag();
bag3.Add(CreateDiagnostic(3));
bag3.Add(CreateDiagnostic(2));
bag3.Add(CreateDiagnostic(1));
bag1.Add(bag3);
Assert.False(bag1.IsEmpty);
Assert.Equal(5, bag1.Count());
}
示例2: EmptyDiagnosticBag
public void EmptyDiagnosticBag()
{
DiagnosticBag bag1 = new DiagnosticBag();
Assert.True(bag1.IsEmpty);
Assert.False(bag1.IsSealed);
Assert.Equal(0, bag1.Count());
Assert.Equal("<no errors>", bag1.ToString());
}
示例3: SealBag
public void SealBag()
{
DiagnosticBag bag1 = new DiagnosticBag();
Assert.False(bag1.IsSealed);
bag1.Add(CreateDiagnostic(4));
bag1.Seal();
Assert.True(bag1.IsSealed);
Assert.Throws<InvalidOperationException>(delegate()
{
bag1.Add(CreateDiagnostic(7));
});
Assert.Equal(1, bag1.Count());
}