本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting.Count方法的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting.Count怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting
的用法示例。
在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestProcess
//.........这里部分代码省略.........
{
new TableElement
{
IsIndex = true,
IsItem = false,
IsItemIf = false,
StartTag = index,
},
new TableElement
{
IsItemIf = true,
IsIndex = false,
IsItem = false,
StartTag = itemIf,
EndTag = endItemIf,
Expression = "./HasSubject",
TagElements =
new TableElement[]
{
new TableElement
{
IsItem = true,
IsIndex = false,
IsItemIf = false,
StartTag = subject,
Expression = "./Subject"
}
}
},
new TableElement
{
IsItem = true,
IsIndex = false,
IsItemIf = false,
StartTag = issueDate,
Expression = "./IssueDate"
},
new TableElement
{
IsItem = true,
IsIndex = false,
IsItemIf = false,
StartTag = expireDate,
Expression = "./ExpireDate"
}
};
return tableElements;
};
tableTag.MakeTableElementCallback = MakeTableElementCallback;
var tableProcessor = new TableProcessor
{
TableTag = tableTag,
DataReader = this.dataReader
};
tableProcessor.Process();
Assert.IsFalse(this.documentRoot.Elements(WordMl.SdtName).Any(element => element.IsSdt()));
var expectedTableStructure = new[]
{
new[] { "#", "Certificate", "Date" },
new[] { string.Empty, string.Empty, "Issue", "Expiration" },
new[] { "1", "2", "3", "4" },
new[] { "1", "Subject1", "01.04.2014", "01.10.2015" },
new[] { "2", "Subject2", "01.03.2014", "01.09.2015" },
new[] { "3", "Subject3", "01.01.2011", "01.01.2012" },
new[] { "This", "row", "stays", "untouched" },
};
var rows = tableTag.Table.Elements(WordMl.TableRowName).ToList();
Assert.AreEqual(expectedTableStructure.Count(), rows.Count());
int rowIndex = 0;
foreach (var row in rows)
{
var expectedRow = expectedTableStructure[rowIndex];
var cellsInRow = row.Elements(WordMl.TableCellName).ToList();
Assert.AreEqual(expectedRow.Count(), cellsInRow.Count());
int cellIndex = 0;
foreach (var cell in cellsInRow)
{
Assert.AreEqual(expectedRow[cellIndex], cell.Value);
cellIndex++;
}
rowIndex++;
}
/*
var tagsBetween =
tableTag.TagTable.ElementsAfterSelf().Where(element => element.IsBefore(tableTag.TagContent));
Assert.IsFalse(tagsBetween.Any());
tagsBetween =
tableTag.TagEndContent.ElementsAfterSelf().Where(element => element.IsBefore(tableTag.TagEndTable));
Assert.IsFalse(tagsBetween.Any());*/
this.ValidateTagsRemoved(this.documentRoot);
}
示例2: TestProcessItemIfCells
public void TestProcessItemIfCells()
{
XElement root;
using (var docStream = AssemblyResourceHelper.GetResourceStream(this, "TableItemIfsTest.xml"))
{
var document = XDocument.Load(docStream);
root = document.Root.Element(WordMl.BodyName);
}
var tableTag = this.GetTableTag(root);
XDocument data;
using (var docStream = AssemblyResourceHelper.GetResourceStream(this, "TableItemIfsData.xml"))
{
data = XDocument.Load(docStream);
}
Func<XElement, IEnumerable<TableElement>> MakeTableElementCallback = element =>
{
var cells = element.Descendants(WordMl.TableCellName).ToList();
ICollection<TableElement> tableElements = new Collection<TableElement>();
foreach (var cell in cells)
{
var cellTags = cell.Descendants(WordMl.SdtName).ToList();
var firtsIf = new TableElement
{
IsIndex = false,
IsItem = false,
IsItemIf = true,
StartTag = cellTags[0],
EndTag = cellTags[2],
Expression = cellTags[0].Value,
TagElements =
new TableElement[]
{
new TableElement
{
IsIndex = false,
IsItemIf = false,
IsItem = true,
StartTag = cellTags[1],
Expression = cellTags[1].Value,
}
}
};
var secondIf = new TableElement
{
IsIndex = false,
IsItem = false,
IsItemIf = true,
StartTag = cellTags[3],
EndTag = cellTags[5],
Expression = cellTags[3].Value,
TagElements =
new TableElement[]
{
new TableElement
{
IsIndex = false,
IsItemIf = false,
IsItem = true,
StartTag = cellTags[4],
Expression = cellTags[4].Value,
}
}
};
tableElements.Add(firtsIf);
tableElements.Add(secondIf);
}
return tableElements;
};
tableTag.MakeTableElementCallback = MakeTableElementCallback;
var tableProcessor = new TableProcessor
{
TableTag = tableTag,
DataReader = DataReaderFactory.CreateReader(data)
};
tableProcessor.Process();
var expectedTableStructure = new[]
{
new[] { "#", "Certificate", "Date" },
new[] { string.Empty, string.Empty, "Issue", "Expiration" },
new[] { "1", "2", "3", "4" },
new[] { "row1 - value1", "row1 - value2", "row1 - value3", "row1 - value4" },
new[] { "row2 - value1", "row2 - value2", "row2 - value3", "row2 - value4" },
new[] { "row3 - value1", "row3 - value2", "row3 - value3", "row3 - value4" },
new[] { "row4 - value1", "row4 - value2", "row4 - value3", "row4 - value4" },
new[] { "row5 - value1", "row5 - value2", "row5 - value3", "row5 - value4" },
new[] { "This", "row", "stays", "untouched" },
};
var rows = tableTag.Table.Elements(WordMl.TableRowName).ToList();
Assert.AreEqual(expectedTableStructure.Count(), rows.Count());
int rowIndex = 0;
foreach (var row in rows)
//.........这里部分代码省略.........
示例3: TestProcessWithStaticCells
public void TestProcessWithStaticCells()
{
XElement root;
using (var docStream = AssemblyResourceHelper.GetResourceStream(this, "TableProcessorWithStaticCellsTest.xml"))
{
var document = XDocument.Load(docStream);
root = document.Root.Element(WordMl.BodyName);
}
var tableTag = this.GetTableTag(root);
Func<XElement, IEnumerable<TableElement>> MakeTableElementCallback = element =>
{
var tags = element.Descendants(WordMl.SdtName).ToList();
var index =
tags.Find(
e =>
e.Element(WordMl.SdtPrName)
.Element(WordMl.TagName)
.Attribute(WordMl.ValAttributeName)
.Value.ToLower()
.Equals("itemindex"));
var issueDate =
tags.Find(
e =>
e.Element(WordMl.SdtPrName)
.Element(WordMl.TagName)
.Attribute(WordMl.ValAttributeName)
.Value.ToLower()
.Equals("itemtext") && e.Element(WordMl.SdtContentName).Value == "./IssueDate");
IEnumerable<TableElement> tableElements = new TableElement[]
{
new TableElement
{
IsIndex = true,
IsItem = false,
IsItemIf = false,
StartTag = index,
},
new TableElement
{
IsItem = true,
IsIndex = false,
IsItemIf = false,
StartTag = issueDate,
Expression = "./IssueDate"
},
};
return tableElements;
};
tableTag.MakeTableElementCallback = MakeTableElementCallback;
var tableProcessor = new TableProcessor
{
TableTag = tableTag,
DataReader = this.dataReader
};
tableProcessor.Process();
var expectedTableStructure = new[]
{
new[] { "#", "Certificate", "Date" },
new[] { string.Empty, string.Empty, "Issue", "Expiration" },
new[] { "1", "2", "3", "4" },
new[] { "1", "First static text", "01.04.2014", "Second static text" },
new[] { "2", "First static text", "01.03.2014", "Second static text" },
new[] { "3", "First static text", "01.01.2011", "Second static text" },
new[] { "This", "row", "stays", "untouched" },
};
var rows = tableTag.Table.Elements(WordMl.TableRowName).ToList();
Assert.AreEqual(expectedTableStructure.Count(), rows.Count());
int rowIndex = 0;
foreach (var row in rows)
{
var expectedRow = expectedTableStructure[rowIndex];
var cellsInRow = row.Elements(WordMl.TableCellName).ToList();
Assert.AreEqual(expectedRow.Count(), cellsInRow.Count());
int cellIndex = 0;
foreach (var cell in cellsInRow)
{
Assert.AreEqual(expectedRow[cellIndex], cell.Value);
cellIndex++;
}
rowIndex++;
}
this.ValidateTagsRemoved(root);
}