本文整理汇总了C#中NUnit.Framework.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFullManifest
public void GenerateFullManifest()
{
ManifestGenerator generator = new ManifestGenerator();
IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
Modification modification1 = GenerateModification("first file", "Add");
Modification modification2 = GenerateModification("second file", "Modify");
result.Modifications = new Modification[] { modification1, modification2 };
List<string> files = new List<string>();
files.Add("first file");
XmlDocument manifest = generator.Generate(result, files.ToArray());
Assert.IsNotNull(manifest);
string actualManifest = manifest.OuterXml;
string expectedManifest = "<manifest>" +
"<header project=\"Test project\" label=\"A Label\" build=\"ForceBuild\" status=\"Unknown\">" +
"<modification user=\"johnDoe\" changeNumber=\"1\" time=\"2009-01-01T00:00:00\">" +
"<comment>A comment</comment>" +
"<file name=\"first file\" type=\"Add\" />" +
"<file name=\"second file\" type=\"Modify\" />" +
"</modification>" +
"</header>" +
"<file name=\"first file\" />" +
"</manifest>";
Assert.AreEqual(expectedManifest, actualManifest);
}
示例2: AllSimpleTests
public void AllSimpleTests()
{
var defaultProvider = MakeDefaultProvider();
var simpleTests = Directory.GetFiles(
Path.GetFullPath(Path.Combine(ComparisonTest.TestSourceFolder, "SimpleTestCases")),
"*.cs"
);
var failureList = new List<string>();
foreach (var filename in simpleTests) {
Console.Write("// {0} ... ", Path.GetFileName(filename));
try {
// We reuse the same type info provider for all the tests in this folder so they run faster
using (var test = new ComparisonTest(filename, null, defaultProvider))
test.Run();
} catch (Exception ex) {
failureList.Add(Path.GetFileNameWithoutExtension(filename));
if (ex.Message == "JS test failed")
Debug.WriteLine(ex.InnerException);
else
Debug.WriteLine(ex);
}
}
Assert.AreEqual(0, failureList.Count,
String.Format("{0} test(s) failed:\r\n{1}", failureList.Count, String.Join("\r\n", failureList.ToArray()))
);
}
示例3: Given_a_stable_live_cell_environment_when_a_moment_passes
public void Given_a_stable_live_cell_environment_when_a_moment_passes()
{
var cell_death_locations = new List<Location>();
var cell_birth_locations = new List<Location>();
var world = World.That_is_a_barren_wasteland();
world.When_a_cell_dies = location => cell_death_locations.Add(location);
world.When_a_cell_comes_to_life = location => cell_birth_locations.Add(location);
world.TouchCellAt(Location.At(0, 0));
world.TouchCellAt(Location.At(0, 1));
world.TouchCellAt(Location.At(1, 0));
world.MomentPassed();
Assert.That(cell_birth_locations, Is.EquivalentTo(new[] { Location.At(0, 0), Location.At(0, 1), Location.At(1, 0), Location.At(1,1) }), "it should have cause the touched cells to be born.");
Assert.That(cell_death_locations.ToArray(), Is.Empty, "No cells should have died.");
cell_death_locations.Clear();
cell_birth_locations.Clear();
world.MomentPassed();
Assert.That(cell_birth_locations, Is.EquivalentTo(Enumerable.Empty<Location>()), "nothing eventful should have happened");
Assert.That(cell_death_locations.ToArray(), Is.Empty, "nothing eventful should have happened");
}
示例4: GetMethodsThroughReflection
/// <summary>
/// This shows how to get the list of overridable methods in the
/// Collection class using reflection only.
/// </summary>
public void GetMethodsThroughReflection()
{
Assembly a = Assembly.Load("mscorlib");
Type t = a.GetType("System.Collections.ObjectModel.Collection`1");
List<string> methodNames = new List<string>();
BindingFlags bindingFlags = BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.DeclaredOnly |
BindingFlags.Public;
foreach (MethodInfo m in t.GetMethods(bindingFlags)) {
if (m.IsVirtual && !m.IsSpecialName && !m.IsFinal) {
methodNames.Add(m.Name);
}
}
List<string> expectedMethodNames = new List<string>();
expectedMethodNames.Add("ClearItems");
expectedMethodNames.Add("InsertItem");
expectedMethodNames.Add("RemoveItem");
expectedMethodNames.Add("SetItem");
StringBuilder sb = new StringBuilder();
foreach (string s in methodNames.ToArray()) {
sb.AppendLine(s);
}
Assert.AreEqual(expectedMethodNames.ToArray(), methodNames.ToArray(), sb.ToString());
}
示例5: TestBatchDeleteAttributes
public void TestBatchDeleteAttributes()
{
List<ReplaceableAttribute> list = new List<ReplaceableAttribute> ();
list.Add (new ReplaceableAttribute ("Test", "Test", true));
List<ReplaceableItem> items = new List<ReplaceableItem> ();
ReplaceableItem item0 = new ReplaceableItem ("0", list);
items.Add (item0);
ReplaceableItem item1 = new ReplaceableItem ("1", list);
items.Add (item1);
BatchPutAttributesRequest request = new BatchPutAttributesRequest ("Test", items);
BatchPutAttributesResponse response = Client.BatchPutAttributes (request).Result;
Assert.AreEqual (HttpStatusCode.OK, response.HttpStatusCode);
List<Attribute> list2 = new List<Attribute> ();
list2.Add (new Attribute ("Test", "Test"));
List<Item> items2 = new List<Item> ();
items2.Add (new Item ("0", list2.ToArray ()));
items2.Add (new Item ("1", list2.ToArray ()));
BatchDeleteAttributesRequest request2 = new BatchDeleteAttributesRequest ("Test", items2);
BatchDeleteAttributesResponse response2 = Client.BatchDeleteAttributes (request2).Result;
Assert.AreEqual (HttpStatusCode.OK, response2.HttpStatusCode);
}
示例6: GetPropertiesThroughReflection
/// <summary>
/// This shows how to get the list of overridable properties in the
/// Exception class using reflection only.
/// </summary>
public void GetPropertiesThroughReflection()
{
Assembly a = Assembly.Load("mscorlib");
Type t = a.GetType("System.Exception");
List<string> propertyNames = new List<string>();
BindingFlags bindingFlags = BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.DeclaredOnly |
BindingFlags.Public;
foreach (PropertyInfo p in t.GetProperties(bindingFlags)) {
MethodInfo m = p.GetGetMethod(true);
if (m.IsVirtual && !m.IsPrivate && !m.IsFinal) {
propertyNames.Add(p.Name);
}
}
List<string> expectedPropertyNames = new List<string>();
expectedPropertyNames.Add("Data");
expectedPropertyNames.Add("HelpLink");
expectedPropertyNames.Add("Message");
expectedPropertyNames.Add("Source");
expectedPropertyNames.Add("StackTrace");
StringBuilder sb = new StringBuilder();
foreach (string s in propertyNames.ToArray()) {
sb.AppendLine(s);
}
Assert.AreEqual(expectedPropertyNames.ToArray(), propertyNames.ToArray(), sb.ToString());
}
示例7: TestHourRollOver
public void TestHourRollOver()
{
VistaDateTimeIterator testIterator = new VistaDateTimeIterator(
new DateTime(2008, 01, 01, 22, 0, 0)
, new DateTime(2008, 01, 03)
, new TimeSpan(1, 0, 0)
);
List<string> values = new List<string>();
while (!testIterator.IsDone())
{
testIterator.SetIterEndDate(); // put at start of loop
values.Add(testIterator.GetDdrListerPart());
testIterator.AdvanceIterStartDate(); // put at end of loop
}
int result = string.Concat(values.ToArray()).GetHashCode();
//Spot Check - Count
Assert.AreEqual(26, values.Count);
String[] strings = values.ToArray();
//Spot Check - Validate Start Value
Assert.IsTrue(strings[0].Equals("3080101.22"));
//Spot Check - Validate End Value
Assert.IsTrue(strings[25].Equals("3080102.23"));
//Spot Check - Validate an Intermediate Value
Assert.IsTrue(strings[14].Equals("3080102.12"));
//Hash Code is not stable acrosss .Net Versions
//Assert.AreEqual(1712919498, result);
}
示例8: ArrayLiterals
public void ArrayLiterals()
{
var array = new[] { 42 };
Assert.AreEqual (typeof(int[]), array.GetType (), "You don't have to specify a type if the elements can be inferred");
Assert.AreEqual (new int[] { 42 }, array, "These arrays are literally equal... But you won't see this string in the error message.");
//Are arrays 0-based or 1-based?
Assert.AreEqual (42, array [0], "Well, it's either 0 or 1.. you have a 110010-110010 chance of getting it right.");
//This is important because...
Assert.IsTrue (array.IsFixedSize, "...because Fixed Size arrays are not dynamic");
//Begin RJG
// Moved this Throws() call to a separate FixedSizeArraysCannotGrow() method below
//...it means we can't do this: array[1] = 13;
//Assert.Throws(typeof(FILL_ME_IN), delegate() { array[1] = 13; });
//End RJG
//This is because the array is fixed at length 1. You could write a function
//which created a new array bigger than the last, copied the elements over, and
//returned the new array. Or you could do this:
var dynamicArray = new List<int> ();
dynamicArray.Add (42);
CollectionAssert.AreEqual (array, dynamicArray.ToArray (), "Dynamic arrays can grow");
dynamicArray.Add (13);
CollectionAssert.AreEqual ((new int[] { 42, (int)13 }), dynamicArray.ToArray (), "Identify all of the elements in the array");
}
示例9: TestCollectionsGroupReturnsCorrectInnerCollectionNames
public void TestCollectionsGroupReturnsCorrectInnerCollectionNames()
{
IEnumerable<string> sectionNames = ConfigurationSection.Collections.SectionNames;
Assert.IsNotNull(sectionNames);
IList<string> names = new List<string>(sectionNames);
Assert.AreEqual(2, names.Count);
Assert.Contains("col1", names.ToArray());
Assert.Contains("col2", names.ToArray());
}
示例10: RunUnprocessOnExistingProcessor
public void RunUnprocessOnExistingProcessor()
{
List<ViewProcessorMapping> mappings = new List<ViewProcessorMapping> ();
mappings.Add(new ViewProcessorMapping(new TypeMatcher().AllOf(view.GetType()).CreateTypeFilter(), trackingProcessor));
viewProcessorFactory.RunProcessors(view, view.GetType(), mappings.ToArray());
viewProcessorFactory.RunUnprocessors(view, view.GetType(), mappings.ToArray());
Assert.That (trackingProcessor.UnprocessedViews, Is.EquivalentTo(new object[1]{ view }));
}
示例11: CopyConstructorPUT
public void CopyConstructorPUT(List<int> values)
{
AvlTree<int> avlTree = new AvlTree<int>(values);
PexAssume.AreDistinctValues<int>(values.ToArray());
List<int> actual = new List<int>(values.Count);
foreach(int i in avlTree)
{
actual.Add(i);
}
CollectionAssert.AreEquivalent(values.ToArray(), actual.ToArray());
}
示例12: BenchmarkPolygons
public void BenchmarkPolygons()
{
var factory = GeometryFactory.Default;
var holes = new List<ILinearRing>(100);
var shell = CreateRing(0, 0, 20, 10000);
Benchmark(factory.CreatePolygon(shell, holes.ToArray()));
for (var i = 0; i < 100; i += 5)
{
holes.Add(CreateRing((i % 10) - 5, (i / 10) - 5, 0.4, 500));
Benchmark(factory.CreatePolygon(shell, holes.ToArray()));
}
}
示例13: TestOptionsParamParser3
public void TestOptionsParamParser3()
{
ParamParser parser = new ParamParser();
List<string> args = new List<string>();
args.Add(TEST_FOLDER);
args.Add("/exclude:TrackChanges");
Assert.IsFalse(parser.Parse(args.ToArray()));
args.Add("/All");
Assert.IsTrue(parser.Parse(args.ToArray()));
}
示例14: GetParaAnalyses
private static AnalysisOccurrence[] GetParaAnalyses(IStTxtPara para)
{
var result = new List<AnalysisOccurrence>();
var point1 = new AnalysisOccurrence(para.SegmentsOS[0], 0);
if (!point1.IsValid)
return result.ToArray();
do
{
if (point1.HasWordform)
result.Add(point1);
point1 = point1.NextWordform();
} while (point1 != null && point1.IsValid);
return result.ToArray();
}
示例15: PathCombineTestCase
public void PathCombineTestCase()
{
var list = new List<String> { @"C:\", "Temp", "Test", "test.xml" };
var expected = Path.Combine( list.ToArray() );
var actual = list.PathCombine();
Assert.AreEqual( expected, actual );
}