当前位置: 首页>>代码示例>>C#>>正文


C# List.ToArray方法代码示例

本文整理汇总了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);
 }
开发者ID:kyght,项目名称:CruiseControl.NET,代码行数:26,代码来源:ManifestGeneratorTests.cs

示例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()))
            );
        }
开发者ID:robashton,项目名称:JSIL,代码行数:29,代码来源:ComparisonTests.cs

示例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");
        }
开发者ID:jcbozonier,项目名称:Conway-s-Game-of-Life--Event-based-,代码行数:25,代码来源:World_Behaviours.cs

示例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());
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:33,代码来源:CollectionClassOverridesTestFixture.cs

示例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);
        }
开发者ID:sadiq81,项目名称:AWSSimpleDBPersistence,代码行数:25,代码来源:TestClient.cs

示例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());
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:35,代码来源:ExceptionClassOverridesTestFixture.cs

示例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);
 }
开发者ID:ChristopherEdwards,项目名称:mdo,代码行数:27,代码来源:VistaDateTimeIteratorTest.cs

示例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");
        }
开发者ID:Khalidsaid,项目名称:CsharpNunitKoans,代码行数:28,代码来源:K040_AboutArrays.cs

示例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());
 }
开发者ID:twistedtwig,项目名称:CustomConfigurations,代码行数:9,代码来源:CollectionsGroup.cs

示例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 }));
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:9,代码来源:ViewProcessorFactoryTest.cs

示例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());
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:11,代码来源:AvlTreeTest.cs

示例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()));
     }
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:12,代码来源:SortedListsFixture.cs

示例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()));
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:13,代码来源:TestParamParser.cs

示例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();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:14,代码来源:InterlinRibbonTests.cs

示例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 );
 }
开发者ID:MannusEtten,项目名称:Extend,代码行数:7,代码来源:IEnumerable[String].PathCombine.Test.cs


注:本文中的NUnit.Framework.List.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。