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


C# List.Sort方法代码示例

本文整理汇总了C#中NUnit.Framework.List.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# List.Sort方法的具体用法?C# List.Sort怎么用?C# List.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NUnit.Framework.List的用法示例。


在下文中一共展示了List.Sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortTest

    public void SortTest ()
    {            
      IChannel fakeIChannel = Isolate.Fake.Instance<IChannel>();

      Card fakeCard1 =  Isolate.Fake.Instance<Card>();
      Isolate.WhenCalled(() => fakeCard1.Priority).WillReturn(3);

      Card fakeCard2 = Isolate.Fake.Instance<Card>();
      Isolate.WhenCalled(() => fakeCard2.Priority).WillReturn(2);

      Card fakeCard3 = Isolate.Fake.Instance<Card>();
      Isolate.WhenCalled(() => fakeCard3.Priority).WillReturn(1);

      var cardDetails = new List<CardDetail>();
      var card = new CardDetail(1, fakeCard1, fakeIChannel, false, 0);
      cardDetails.Add(card);
      card = new CardDetail(2, fakeCard2, fakeIChannel, false, 0);
      cardDetails.Add(card);
      card = new CardDetail(3, fakeCard3, fakeIChannel, true, 1);
      cardDetails.Add(card);

      cardDetails.Sort();

      List<CardDetail> freeCards =
          cardDetails.Where(t => t.NumberOfOtherUsers == 0 || (t.NumberOfOtherUsers > 0 && t.SameTransponder)).ToList();
      List<CardDetail> availCards = cardDetails.Where(t => t.NumberOfOtherUsers > 0 && !t.SameTransponder).ToList();
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:27,代码来源:CardDetailTest.cs

示例2: DiscoverAllTestClasses

        /// <summary>
        /// Gets list of all test classes obtained by inspecting all the test assemblies.
        /// </summary>
        private Dictionary<string, List<string>> DiscoverAllTestClasses()
        {
            var assemblies = GetTestAssemblies();

            var testsByAssembly = new Dictionary<string, List<string>>();
            foreach (var assembly in assemblies)
            {
                var testClasses = new List<string>();
                foreach (var t in assembly.GetTypes())
                {
                    foreach (var m in t.GetMethods())
                    {
                        var attributes = m.GetCustomAttributes(typeof(NUnit.Framework.TestAttribute), true);
                        if (attributes.Length > 0)
                        {
                            testClasses.Add(t.FullName);
                            break;
                        }

                    }
                }
                testClasses.Sort();
                testsByAssembly.Add(assembly.GetName().Name, testClasses);
            }
            return testsByAssembly;
        }
开发者ID:yjydnpy,项目名称:grpc,代码行数:29,代码来源:SanityTest.cs

示例3: AllFiltersHaveTests

        public void AllFiltersHaveTests()
        {
            List<Type> tests = this.GetTestClasses();
            List<Type> filters = this.GetFilters();
            List<string> missingTests = new List<string>();

            foreach ( Type filter in filters ) {

                string name = filter.Name + "Tests";

                Type testType = tests.Find( t => t.Name == name );
                if ( testType == null ) {
                    // Test is missing
                    missingTests.Add( filter.Name );

                } else {
                    // Is it testing the right type?
                    FilterBaseTest test = (FilterBaseTest)Activator.CreateInstance( testType );
                    Assert.AreEqual( filter.FullName, test.TestType.FullName );
                }
            }

            missingTests.Sort();

            Assert.AreEqual( 0, missingTests.Count, "Missing tests for these filters: " + string.Join( ", ", missingTests.ToArray() ) );
        }
开发者ID:robrich,项目名称:NAntTasks,代码行数:26,代码来源:TestForEachFilterTests.cs

示例4: Full

        public void Full()
        {
            Console.WriteLine("Full");
            Init();

            List<string> files = new List<string>(Directory.GetFiles(basePath, "*.rc", SearchOption.AllDirectories));
            files.AddRange(Directory.GetFiles(basePath, "*.red", SearchOption.AllDirectories));
            files.Sort();
            bool allOK = true;
            int c = 0;
            for (int i = 0; i < files.Count; i++)
            {
                for (int j = 0; j < files.Count; j++)
                {
                    try
                    {
                        LoadRunPair(files[i], files[j], c);
                        c++;
                    }
                    catch (EngineDifferException)
                    {
                        Console.WriteLine("\nFailed");
                        allOK = false;
                    }
                    catch (ParserException)
                    {
                        //swallow
                    }
                }
            }
            Console.WriteLine("\nDone");
            if (!allOK)
                throw new EngineDifferException("Some warriors failed.", null);
        }
开发者ID:pavelsavara,项目名称:nMars,代码行数:34,代码来源:EngineTest.cs

示例5: TestSort

    public void TestSort()
    {
      IdentifiedSpectrum sp1 = new IdentifiedSpectrum();
      sp1.Query.FileScan.LongFileName = "YEAST_0612_G1_SAX_080806_09.17702.17702.2.out";
      new IdentifiedPeptide(sp1) { Sequence = "K.GFFSFATQK.L" };

      IdentifiedSpectrum sp2 = new IdentifiedSpectrum();
      sp2.Query.FileScan.LongFileName = "YEAST_0612_G1_SAX_080806_09.17707.17708.1.out";
      new IdentifiedPeptide(sp2) { Sequence = "K.GFFSFATQK.L" };

      IdentifiedSpectrum sp3 = new IdentifiedSpectrum();
      sp3.Query.FileScan.LongFileName = "YEAST_0612_G1_SAX_080806_09.7707.7708.2.out";
      new IdentifiedPeptide(sp3) { Sequence = "K.GFFSFATQK.L" };

      IdentifiedSpectrum sp4 = new IdentifiedSpectrum();
      sp4.Query.FileScan.LongFileName = "YEAST_0612_G1_SAX_080806_09.7707.7708.2.out";
      new IdentifiedPeptide(sp4) { Sequence = "K.AAAAAAAK.L" };

      List<IIdentifiedSpectrum> spectra = new List<IIdentifiedSpectrum>();
      spectra.Add(sp2);
      spectra.Add(sp1);
      spectra.Add(sp3);
      spectra.Add(sp4);

      spectra.Sort();

      Assert.AreSame(sp4, spectra[0]);
      Assert.AreSame(sp3, spectra[1]);
      Assert.AreSame(sp1, spectra[2]);
      Assert.AreSame(sp2, spectra[3]);
    }
开发者ID:shengqh,项目名称:RCPA.Test,代码行数:31,代码来源:TestIdentifiedSpectrum.cs

示例6: Sort_Should_Return_Promotions_OrderedBy_Date_Descending

        public void Sort_Should_Return_Promotions_OrderedBy_Date_Descending()
        {
            List<Promotion> promotions = new List<Promotion>
            {

                new Promotion
                {
                    RankDate = new System.DateTime(2011, 2, 2, 0, 0, 0, 0)
                },
                new Promotion
                {
                    RankDate = new System.DateTime(2001, 2, 2, 0, 0, 0, 0)
                },
                new Promotion
                {
                    RankDate = new System.DateTime(2009, 2, 2, 0, 0, 0, 0)
                },

                new Promotion
                {
                    RankDate = new System.DateTime(2003, 2, 2, 0, 0, 0, 0)
                },
                new Promotion
                {
                    RankDate = new System.DateTime(2015, 2, 2, 0, 0, 0, 0)
                }
            };

            promotions.Sort();
            Assert.AreEqual( 2015, promotions[0].RankDate.Value.Year);
        }
开发者ID:thorjarhun,项目名称:auskf,代码行数:31,代码来源:PromotionsTests.cs

示例7: TestStdOutput

        public void TestStdOutput()
        {
            using (ProcessRunner runner = new ProcessRunner("cmd.exe"))
            {
                StringWriter wtr = new StringWriter();
                StringWriter err = new StringWriter();
                ProcessOutputEventHandler handler =
                        delegate(object o, ProcessOutputEventArgs e)
                        { if (e.Error) err.WriteLine(e.Data); else wtr.WriteLine(e.Data); };

                runner.OutputReceived += handler;

                Assert.AreEqual(0, runner.Run("/C", "dir", "/b", "/on", "/ad-h-s", "c:\\"));
                Assert.AreEqual(String.Empty, err.ToString());

                Assert.AreNotEqual(0, runner.PID);

                StringReader rdr = new StringReader(wtr.ToString());
                List<DirectoryInfo> rootdirs = new List<DirectoryInfo>(new DirectoryInfo("C:\\").GetDirectories());
                rootdirs.Sort(delegate(DirectoryInfo x, DirectoryInfo y) { return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name); });
                foreach (DirectoryInfo di in rootdirs)
                {
                    if ((di.Attributes & (FileAttributes.Hidden | FileAttributes.System)) != 0)
                        continue;
                    Assert.AreEqual(di.Name, rdr.ReadLine());
                }

                Assert.AreEqual(null, rdr.ReadLine());
            }
        }
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:30,代码来源:TestProcessRunner.cs

示例8: SetUp

        public override void SetUp()
        {
            base.SetUp();
            Dir = NewDirectory();
            FieldName = Random().NextBoolean() ? "field" : ""; // sometimes use an empty string as field name
            RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
            Document doc = new Document();
            Field field = NewStringField(FieldName, "", Field.Store.NO);
            doc.Add(field);
            List<string> terms = new List<string>();
            int num = AtLeast(200);
            for (int i = 0; i < num; i++)
            {
                string s = TestUtil.RandomUnicodeString(Random());
                field.StringValue = s;
                terms.Add(s);
                writer.AddDocument(doc);
            }

            if (VERBOSE)
            {
                // utf16 order
                terms.Sort();
                Console.WriteLine("UTF16 order:");
                foreach (string s in terms)
                {
                    Console.WriteLine("  " + UnicodeUtil.ToHexString(s));
                }
            }

            Reader = writer.Reader;
            Searcher1 = NewSearcher(Reader);
            Searcher2 = NewSearcher(Reader);
            writer.Dispose();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:35,代码来源:TestRegexpRandom2.cs

示例9: Test_GetAllFiles_SanityCheck

        public void Test_GetAllFiles_SanityCheck()
        {
            _fileData = TestUtils.GetAnyFileData (FileSize.SMALL_FILE_SIZE);

            int numFilesToSave = TYPICAL_MULTI_VALUE;

            List<ulong> fileIDs = new List<ulong> ();
            for (int i = 0; i < numFilesToSave; ++i) {
                string fileName = TestUtils.GetAnyFileName ();
                DateTime when = DateTime.Now.AddYears (i - numFilesToSave / 2);
                ulong fileID = SaveFileToMfs (ref _mfsOperations, _fileName, _fileNarration, _fileData, when, false);

                fileIDs.Add (fileID);
            }

            List<ulong> allFileIDs = _mfsOperations.File.GetAll ();
            Assert.AreEqual (TYPICAL_MULTI_VALUE, allFileIDs.Count, "Incorrect number of files retrieved.");

            fileIDs.Sort ();
            allFileIDs.Sort ();

            for (int i = 0; i < fileIDs.Count; ++i) {
                Assert.AreEqual (fileIDs[i], allFileIDs[i], "Incorrect file retrieved.");
            }

            foreach (ulong fileID in fileIDs) {
                _mfsOperations.File.Delete (fileID);
            }
        }
开发者ID:cryptonome,项目名称:mnemonicfs,代码行数:29,代码来源:TestDateTimeFilter.cs

示例10: LoadAndReplay

		public void LoadAndReplay()
		{
			var dir = new DirectoryInfo(@"C:\Code\AIGames.Challenger\games\texas-hold-em");

			var bot = new ACDCBot();
			bot.Actor.Nodes.Clear();

			foreach (var file in dir.GetFiles("*.log"))
			{
				using (var platform = new ConsolePlatformTester(file))
				{
					platform.DoRun(bot);
				}
			}
			var nodes = new List<Node>(bot.Actor.Nodes);
			nodes.Sort();
			nodes.Save(new FileInfo(@"C:\temp\data.bin"));
			using (var writer = new StreamWriter(@"C:\temp\data.log"))
			{
				foreach (var node in nodes)
				{
					writer.WriteLine(node);
				}
			}
		}
开发者ID:Corniel,项目名称:AIGames.TexasHoldEm.ACDC,代码行数:25,代码来源:HistoryLoading.cs

示例11: Setup

 public void Setup(int maxTasksInPool, int tasksToFork)
 {
     AtomicInteger atomicVal = new AtomicInteger();
     IExecutorService execService = new LimitedTaskExecutorService(maxTasksInPool);
     ICollection<IFuture<int>> futures = new List<IFuture<int>>(tasksToFork);
     for (int i = 0; i < tasksToFork; i++)
     {
         var task = new FutureTask<int>(CallableUtils.FromFunc(() =>
         {
             Thread.Yield();
             Thread.Sleep(7);
             int value = atomicVal.IncrementAndGet();
             Thread.Yield();
             return value;
         }));
         IFuture<int> future = execService.submit(task);
         futures.Add(future);
     }
     var results = new List<int>();
     foreach (IFuture<int> future in futures)
     {
         int value = future.get();
         results.Add(value);
     }
     results.Sort();
     int prevValue = results[0];
     Console.WriteLine(prevValue);
     for (int i = 1; i < results.Count; i++)
     {
         Console.WriteLine(results[i]);
         Assert.AreEqual(prevValue + 1, results[i]);
         prevValue = results[i];
     }
     Assert.AreEqual(atomicVal.Get(), tasksToFork);
 }
开发者ID:Lagrang,项目名称:CuratorNet,代码行数:35,代码来源:LimitedTaskExecutorService.cs

示例12: GetClosest

    /// <summary>Returns at most the 4 closest addresses in order.</summary>
    protected List<Connection> GetClosest(List<Connection> cons)
    {
      List<Connection> closest = new List<Connection>(cons);

      // Since MeasuredLatency could change the duration of our sorting we make
      // a copy as necessary
      Dictionary<Connection, double> latencies = new Dictionary<Connection, double>();

      Comparison<Connection> comparer = delegate(Connection x, Connection y) {
        double lat_x, lat_y;
        if(!latencies.TryGetValue(x, out lat_x)) {
          lat_x = _ncservice.GetMeasuredLatency(x.Address);
          latencies[x] = lat_x;
        }
        if(!latencies.TryGetValue(y, out lat_y)) {
          lat_y = _ncservice.GetMeasuredLatency(y.Address);
          latencies[y] = lat_y;
        }

        // Remember that smaller is better but -1 is bad...
        // If either is smaller than 0 invert the comparison..
        if(lat_x < 0 || lat_y < 0) {
          return lat_y.CompareTo(lat_x);
        } else {
          return lat_x.CompareTo(lat_y);
        }
      };

      closest.Sort(comparer);
      if(closest.Count > 4) {
        closest.RemoveRange(4, closest.Count - 4);
      }
      return closest;
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:35,代码来源:NCTunnelOverlap.cs

示例13: SignatureParameterShouldSortByNameAndValueUsingAscendingByteValueOrdering

        public void SignatureParameterShouldSortByNameAndValueUsingAscendingByteValueOrdering()
        {
            List<BaseStringParameter> sortedParameters = new List<BaseStringParameter>()
            {
                new BaseStringParameter("a2", "r%20b"),
                new BaseStringParameter("a3", "2%20q"),
                new BaseStringParameter("a3", "a"),
                new BaseStringParameter("b5", "%3D%253D"),
                new BaseStringParameter("c%40", ""),
                new BaseStringParameter("c2", ""),
                new BaseStringParameter("oauth_consumer_key", "9djdj82h48djs9d2"),
                new BaseStringParameter("oauth_nonce", "7d8f3e4a"),
                new BaseStringParameter("oauth_signature_method", "HMAC-SHA1"),
                new BaseStringParameter("oauth_timestamp", "137131201"),
                new BaseStringParameter("oauth_token", "kkk9d7dh3k39sjv7")
            };

            List<BaseStringParameter> parameters = new List<BaseStringParameter>(sortedParameters);
            parameters.Shuffle();

            parameters.Sort(new BaseStringParameterComparer());

            // Since version 2.2, NUnit has been able to compare two single-dimensioned arrays.
            // Two arrays or collections will be treated as equal by Assert.AreEqual if they
            // have the same dimensions and if each of the corresponding elements is equal.
            Assert.That(parameters, Is.EqualTo(sortedParameters));
        }
开发者ID:MathieuTurcotte,项目名称:CSharp-OAuth-Client-Library,代码行数:27,代码来源:BaseStringParameterComparerTest.cs

示例14: TestSort

    public void TestSort()
    {
      var mph1 = new IdentifiedSpectrum();
      var peptide1 = new IdentifiedPeptide(mph1);

      var mph2 = new IdentifiedSpectrum();
      var peptide2 = new IdentifiedPeptide(mph2);

      var mpro1 = new IdentifiedProtein("Protein1");
      mpro1.Peptides.Add(peptide1);
      mpro1.Peptides.Add(peptide2);

      var mpro2 = new IdentifiedProtein("Protein2");
      mpro2.Peptides.Add(peptide1);

      var mpro3 = new IdentifiedProtein("Protein3");
      mpro3.Peptides.Add(peptide2);

      var mpros = new List<IdentifiedProtein>();
      mpros.Add(mpro3);
      mpros.Add(mpro2);
      mpros.Add(mpro1);

      mpros.Sort();

      Assert.AreEqual(mpro1, mpros[0]);
      Assert.AreEqual(mpro2, mpros[1]);
      Assert.AreEqual(mpro3, mpros[2]);
    }
开发者ID:shengqh,项目名称:RCPA.Test,代码行数:29,代码来源:TestMascotProtein.cs

示例15: AutomaticallyFindRegistryFromAssembly

        public void AutomaticallyFindRegistryFromAssembly()
        {
            var container = new Container(x =>
            {
                x.Scan(s =>
                {
                    s.AssemblyContainingType<RedGreenRegistry>();
                    s.LookForRegistries();
                });
            });

            var colors = new List<string>();
            foreach (var widget in container.GetAllInstances<IWidget>())
            {
                if (!(widget is ColorWidget))
                {
                    continue;
                }

                var color = (ColorWidget) widget;
                colors.Add(color.Color);
            }

            colors.Sort();
            colors.ShouldHaveTheSameElementsAs("Black", "Blue", "Brown", "Green", "Red", "Yellow");
        }
开发者ID:RANENTONG,项目名称:structuremap,代码行数:26,代码来源:RegistryIntegratedTester.cs


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