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


C# List.RemoveRange方法代码示例

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


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

示例1: PlayExecutesSamePlayerOrderInEachRound

        public void PlayExecutesSamePlayerOrderInEachRound()
        {
            var players = new[]
            {
                "Horse",
                "Car",
                "Hat"
            };

            var mockTurn = new Mock<ITurn>();
            var game = new Game(players, mockTurn.Object, new GuidShuffler<String>());
            var controller = new GameController(game);
            var turnsTaken = new List<String>();

            mockTurn.Setup(m => m.Take(It.IsAny<String>())).Callback((String p) => turnsTaken.Add(p));
            controller.Play();

            var lastRoundTurns = Enumerable.Empty<String>();

            while (turnsTaken.Any())
            {
                var roundTurns = turnsTaken.Take(players.Count());

                if (lastRoundTurns.Any())
                {
                    for (var i = 0; i < lastRoundTurns.Count(); i++)
                        Assert.AreEqual(roundTurns.ElementAt(i), lastRoundTurns.ElementAt(i));
                }

                lastRoundTurns = roundTurns;
                turnsTaken.RemoveRange(0, players.Count());
            }
        }
开发者ID:kawillia,项目名称:MonopolyKataRoundTwo,代码行数:33,代码来源:GameControllerTests.cs

示例2: TestEncodeDecodeWithCompression

        public void TestEncodeDecodeWithCompression()
        {
            var input =
            "He paused for a moment, many recollections overpowering him. Then he went on telling her the history of his life, unfolding to her the story of his hopes and ambitions, describing to her the very home where he was born, and the dark-eyed sister whom he had loved, and with whom he had played over the daisied fields, and through the carpeted woods, and all among the richly tinted bracken. One day he was told she was dead, and that he must never speak her name; but he spoke it all the day and all the night, Beryl, nothing but Beryl, and he looked for her in the fields and in the woods and among the bracken. It seemed as if he had unlocked the casket of his heart, closed for so many years, and as if all the memories of the past and all the secrets of his life were rushing out, glad to be free once more, and grateful for the open air of sympathy.";

             var dict = CharacterFrequencyDictionary.CreateDictionary(input);

             var encodeTree = new HuffmanTree<char>(dict);

             var encode = encodeTree.Encode(input);

             var encodeAsByte = CompressUtil.ConvertToByteArray(encode);

             var secondDict = CharacterFrequencyDictionary.CreateDictionary(
            dict.GetKeysAsByteArray(), dict.GetValuesAsByteArray());

             var encodeAsByteArray = new List<byte>();
             foreach (var b in encodeAsByte)
            encodeAsByteArray.AddRange(CompressUtil.ConvertToBitArray(b));

             if (encode.Length < encodeAsByteArray.ToArray().Length)
            encodeAsByteArray.RemoveRange(encode.Length, encodeAsByteArray.ToArray().Length - encode.Length);

             CollectionAssert.AreEqual(dict, secondDict);
             CollectionAssert.AreEqual(encode, encodeAsByteArray.ToArray());

             var decodeTree = new HuffmanTree<char>(secondDict);
             var decode = decodeTree.Decode(encodeAsByteArray);

             Assert.AreEqual(input, decode);
        }
开发者ID:rsgoheen,项目名称:Compress,代码行数:31,代码来源:HuffmanTreeTest.cs

示例3: RemoveRange

        public void RemoveRange()
        {
            // Type
            var @this = new List<string> {"zA", "zB", "C"};

            // Exemples
            @this.RemoveRange("zA", "zB"); // Remove "zA" and "zB" items

            // Unit Test
            Assert.AreEqual(1, @this.Count);
        }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:11,代码来源:ICollection[T].RemoveRange.cs

示例4: TestDistinctCopy_CreateSet

        public void TestDistinctCopy_CreateSet()
        {
            Random random = new Random();

            // build a list of random numbers
            var list = new List<int>(100);
            Sublist.Generate(100, i => random.Next(100)).AddTo(list.ToSublist());

            // unique requires that elements be sorted
            list.ToSublist().Sort().InPlace();

            // now we create a set from the list
            var destination = new List<int>(100);
            Sublist.Generate(100, 0).AddTo(destination.ToSublist());
            int result = list.ToSublist().Distinct().CopyTo(destination.ToSublist());
            destination.RemoveRange(result, destination.Count - result); // remove dangling elements

            // check that we have a valid set
            bool isSet = destination.ToSublist().IsSet();
            Assert.IsTrue(isSet, "The destinatin was not a valid set.");
        }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:21,代码来源:DistinctCopyTester.cs

示例5: TestPop

        public void TestPop()
        {
            var dynamicStack = new DynamicStack<int>();
            var list = new List<object>();
            for (int i = 0; i < 1000; i++)
            {
                dynamicStack.Push(i);
                list.Add(i);
            }

            for (int i = 0; i < 50; i++)
            {
                dynamicStack.Pop();

            }
            list.RemoveRange(950, 50);
            list.Reverse();
            var expected = list.ToArray();
            var actual = dynamicStack.ToArray();

            CollectionAssert.AreEqual(expected, actual);
        }
开发者ID:BobbyBorisov,项目名称:TelerikAcademy,代码行数:22,代码来源:UnitTest1.cs

示例6: LDiffExperimentZ3

        private static void LDiffExperimentZ3(BitWidth encoding)
        {
            List<string> regexes = new List<string>(SampleRegexes.regexes);
            regexes.RemoveRange(2, regexes.Count - 2); //just consider the first 5 cases

            long timeout = 5 * Microsoft.Automata.Internal.Utilities.HighTimer.Frequency; //5 sec

            for (int i = 0; i < regexes.Count; i++)
                for (int j = 0; j < regexes.Count; j++)
                {
                    string regexA = regexes[i];
                    string regexB = regexes[j];

                    var z3p = new Z3Provider(encoding);

                    z3p.MainSolver.Push();

                    var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
                    var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);
                    //A.ShowGraph();
                    try
                    {
                        List<Expr> witness;
                        var AmB = Automaton<Expr>.MkDifference(A, B, (int)timeout).Determinize().Minimize();
                        //AmB.ShowGraph();
                        bool isNonempty = Automaton<Expr>.CheckDifference(A, B, (int)timeout, out witness);
                        if (isNonempty)
                        {
                            string s = new String(Array.ConvertAll(witness.ToArray(), c => z3p.GetCharValue(z3p.MainSolver.FindOneMember(c).Value)));
                            Assert.IsTrue(Regex.IsMatch(s, regexA), s + " must match " + regexA);
                            Assert.IsFalse(Regex.IsMatch(s, regexB), s + " must not match " + regexB);
                        }
                    }
                    catch (TimeoutException)
                    {
                        Console.WriteLine("Timeout {0},{1}", i, j);
                    }

                    z3p.MainSolver.Pop();
                }
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:41,代码来源:FiniteAutomataTests.cs

示例7: DiffExperimentZ3

        private static void DiffExperimentZ3(BitWidth encoding)
        {
            List<string> regexes = new List<string>(SampleRegexes.regexes);
            regexes.RemoveRange(3, regexes.Count - 3); //just consider the first few cases

            long timeout = 5 * Microsoft.Automata.Internal.Utilities.HighTimer.Frequency; //5 sec

            for (int i = 0; i < regexes.Count; i++)
                if (i != 6)
                    for (int j = 0; j < regexes.Count; j++)
                    {
                        string regexA = regexes[i];
                        string regexB = regexes[j];

                        var z3p = new Z3Provider(encoding);

                        z3p.MainSolver.Push();

                        var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
                        var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);
                        try
                        {
                            var C = Automaton<Expr>.MkDifference(A, B, (int)timeout);
                            if (!C.IsEmpty)
                            {
                                string s = GetMember(z3p, C);
                                Assert.IsTrue(Regex.IsMatch(s, regexA), s + " must match " + regexA);
                                Assert.IsFalse(Regex.IsMatch(s, regexB), s + " must not match " + regexB);
                            }
                        }
                        catch (TimeoutException)
                        {
                            Console.WriteLine("Timeout {0},{1}", i, j);
                        }

                        z3p.MainSolver.Pop();
                    }
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:38,代码来源:FiniteAutomataTests.cs

示例8: ProdTest

        public void ProdTest()
        {
            BitWidth encoding = BitWidth.BV7;

            List<string> regexes = new List<string>(SampleRegexes.regexes);
            regexes.RemoveRange(6, regexes.Count - 6); //just consider the first 6 cases

            int nonemptyCount = 0;

            for (int i = 0; i < regexes.Count; i++)
                for (int j = 0; j < regexes.Count; j++)
                {

                    string regexA = regexes[i];
                    string regexB = regexes[j];

                    var z3p = new Z3Provider(encoding);

                    z3p.MainSolver.Push();

                    var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
                    var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);

                    var A1 = z3p.CharSetProvider.Convert(regexA);
                    var B1 = z3p.CharSetProvider.Convert(regexB);

                    var C1 = Automaton<BDD>.MkProduct(A1, B1).Determinize().Minimize();

                    var C = Automaton<Expr>.MkProduct(A, B);
                    var C2 = new SFAz3(z3p, z3p.CharSort, C.Determinize().Minimize()).Concretize(200);

                    var equiv = C1.IsEquivalentWith(C1);
                    Assert.IsTrue(equiv);

                    if (i == j)
                        Assert.IsFalse(C.IsEmpty);
                    if (!C.IsEmpty)
                    {
                        if (i != j)
                        {
                            //z3p.CharSetProvider.ShowGraph(C1, "C1");
                            //z3p.CharSetProvider.ShowGraph(C2, "C2");
                        }

                        nonemptyCount += 1;
                        string s = GetMember(z3p, C);
                        Assert.IsTrue(Regex.IsMatch(s, regexA, RegexOptions.None), "regex mismatch");
                        Assert.IsTrue(Regex.IsMatch(s, regexB, RegexOptions.None), "regex mismatch");
                    }

                    z3p.MainSolver.Pop();
                }
            Assert.AreEqual<int>(10, nonemptyCount, "wrong number of empty intersections");
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:54,代码来源:FiniteAutomataTests.cs

示例9: ApplyChange

 public byte[] ApplyChange(byte[] inputFile)
 {
     List<byte> result = new List<byte>(inputFile);
     int type = r.Next(3);
     switch (type)
     {
         case 0:
             // just change a byte
             result[r.Next(result.Count)] = (byte)r.Next(256);
             break;
         case 1:
             // insert some bytes
             var randBytes = new byte[r.Next(1000)];
             r.NextBytes(randBytes);
             result.InsertRange(r.Next(result.Count), randBytes);
             break;
         case 2:
             // delete some bytes
             result.RemoveRange(r.Next(result.Count), r.Next(100));
             break;
     }
     return result.ToArray();
 }
开发者ID:nalfeo,项目名称:librsync.net,代码行数:23,代码来源:RoundTripTest.cs

示例10: checkingOrderOfCollection

        public void checkingOrderOfCollection(string CassandraCollectionType, Type TypeOfDataToBeInputed, Type TypeOfKeyForMap = null, string pendingMode = "")
        {
            string cassandraDataTypeName = QueryTools.convertTypeNameToCassandraEquivalent(TypeOfDataToBeInputed);
            string cassandraKeyDataTypeName = "";

            string openBracket = CassandraCollectionType == "list" ? "[" : "{";
            string closeBracket = CassandraCollectionType == "list" ? "]" : "}";
            string mapSyntax = "";

            string randomKeyValue = string.Empty;

            if (TypeOfKeyForMap != null)
            {
                cassandraKeyDataTypeName = QueryTools.convertTypeNameToCassandraEquivalent(TypeOfKeyForMap);
                mapSyntax = cassandraKeyDataTypeName + ",";

                if (TypeOfKeyForMap == typeof(DateTimeOffset))
                    randomKeyValue = (string)(Randomm.RandomVal(typeof(DateTimeOffset)).GetType().GetMethod("ToString", new Type[] { typeof(string) }).Invoke(Randomm.RandomVal(typeof(DateTimeOffset)), new object[1] { "yyyy-MM-dd H:mm:sszz00" }) + "' : '");
                else
                    randomKeyValue = Randomm.RandomVal(TypeOfDataToBeInputed) + "' : '";
            }

            string tableName = "table" + Guid.NewGuid().ToString("N");
            try
            {
                Session.Cluster.WaitForSchemaAgreement(
                    QueryTools.ExecuteSyncNonQuery(Session, string.Format(@"CREATE TABLE {0}(
             tweet_id uuid PRIMARY KEY,
             some_collection {1}<{2}{3}>
             );", tableName, CassandraCollectionType, mapSyntax, cassandraDataTypeName)));
            }
            catch (AlreadyExistsException)
            {
            }
            Guid tweet_id = Guid.NewGuid();

            StringBuilder longQ = new StringBuilder();
            longQ.AppendLine("BEGIN BATCH ");

            int CollectionElementsNo = 100;
            List<Int32> orderedAsInputed = new List<Int32>(CollectionElementsNo);

            string inputSide = "some_collection + {1}";
            if (CassandraCollectionType == "list" && pendingMode == "prepending")
                inputSide = "{1} + some_collection";

            for (int i = 0; i < CollectionElementsNo; i++)
            {
                var data = i * (i % 2);
                longQ.AppendFormat(@"UPDATE {0} SET some_collection = " + inputSide + " WHERE tweet_id = {2};"
                    , tableName, openBracket + randomKeyValue + data + closeBracket, tweet_id.ToString());
                orderedAsInputed.Add(data);
            }

            longQ.AppendLine("APPLY BATCH;");
            QueryTools.ExecuteSyncNonQuery(Session, longQ.ToString(), "Inserting...");

            if (CassandraCollectionType == "set")
            {
                orderedAsInputed.Sort();
                orderedAsInputed.RemoveRange(0, orderedAsInputed.LastIndexOf(0));
            }
            else if (CassandraCollectionType == "list" && pendingMode == "prepending")
                orderedAsInputed.Reverse();

            CqlRowSet rs = Session.Execute(string.Format("SELECT * FROM {0};", tableName), ConsistencyLevel.Default);

            using (rs)
            {
                int ind = 0;
                foreach (var row in rs.GetRows())
                    foreach (var value in row[1] as System.Collections.IEnumerable)
                    {
                        Assert.True(orderedAsInputed[ind] == (int)value);
                        ind++;
                    }
            }

            QueryTools.ExecuteSyncQuery(Session, string.Format("SELECT * FROM {0};", tableName));
            QueryTools.ExecuteSyncNonQuery(Session, string.Format("DROP TABLE {0};", tableName));
        }
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:81,代码来源:Collections.cs

示例11: TestWhereCopy_RemoveOddItems

        public void TestWhereCopy_RemoveOddItems()
        {
            var list = new List<int>() { 1, 2, 3, 4, 5, 6 };
            // only keep the even items
            int result = list.ToSublist().Where(item => item % 2 == 0).CopyTo(list.ToSublist());
            list.RemoveRange(result, list.Count - result);

            int[] expected = { 2, 4, 6 };
            Assert.IsTrue(expected.ToSublist().IsEqualTo(list.ToSublist()), "The items were not where they were expected.");
        }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:10,代码来源:WhereCopyTester.cs

示例12: _02_02_CollectionsGenerischTest

        public void _02_02_CollectionsGenerischTest()
        {
            var meinArray = new ArrayInt(5);

            // Compiler wandelt folgende Zeile um in
            // meinArray.this[0].set(2)
            meinArray[0] = 2;
            meinArray[1] = 3;
            meinArray[2] = 5;
            meinArray[3] = 7;
            meinArray[4] = 11;

            int a = meinArray[3];

            for (int i = 0; i < meinArray.Length; i++)
            {
                meinArray[i] = i * 10;
            }

            // Dank IEnumarable können wir auf dem selbsdefinierten Array mittels 
            // einer foreach- Schleife iterieren

            foreach (int elem in meinArray)
            {
                Debug.WriteLine(elem);
            }

            int sum = 0;
            for (int i = 0; i < meinArray.Length; i++)
                // Compiler wandelt folgende Zeile um in
                // meinArray.this[i].get()
                sum += meinArray[i];

            // jetzt den generischen Typ nutzen
            var PreislisteGen = new ArrayGenerisch<Preis>(3);

            PreislisteGen[0] = new Preis(4, 99);
            PreislisteGen[1] = new Preis(1, 99);
            PreislisteGen[2] = new Preis(2, 29);

            var p1 = PreislisteGen[1];           


            var A8 = new ArrayGenerisch<Basics._04_Objektorientiert.Autobahn.Auto>(3);

            //A8[0].tanken(100);

            var deinArray = new ArrayGenerisch<double>(3);

            deinArray[0] = 3.14;
            deinArray[1] = 2.72;
            deinArray[2] = 9.81;

            // deinArray ist streng typisiert
            //deinArray[2] = "Hallo";

            double dblSum = 0;
            for (int i = 0; i < deinArray.Length; i++)
                dblSum += deinArray[i];


            // Vorgefertigte generische Collections einsetzen

            // 1) List- ein dynamischer Ersatz für Arrays
            var Preisliste = new List<Preis>(10);

            FüllePreisliste(Preisliste);

            // Compiler wandelt folgenden Aufruf um in
            // Preisliste.this[3].get()
            var preis3 = Preisliste[3];
            Assert.AreEqual(8, preis3.GetEuro());
            Assert.AreEqual(8, Preisliste[3].GetEuro());

            // Einen Preis aus der Liste entfernen
            Preisliste.RemoveAt(0); // 1. Element entfernen
            Preisliste.RemoveAt(Preisliste.Count - 1); // letztes Element entfernen
            Preisliste.RemoveRange(1, 2);

            FüllePreisliste(Preisliste);

            // Linked List
            var AktuellePreise = new LinkedList<string>();
            foreach (var p in Preisliste)
            {
                AktuellePreise.AddLast(p.ToString());
            }

            foreach (var el in AktuellePreise)
            {
                Debug.WriteLine(el);
            }

            // Iterieren über die LinkedList vorwärts
            LinkedListNode<string> actNode = null;
            for (actNode = AktuellePreise.First; actNode != null; actNode = actNode.Next)
            {
                Debug.WriteLine("preis: " + actNode.Value);

            }
//.........这里部分代码省略.........
开发者ID:mk-prg-net,项目名称:CSharp45.Basics,代码行数:101,代码来源:_02_02_CollectionsTests.cs

示例13: FilterStackTrace

        private static List<StackFrame> FilterStackTrace(Exception e)
        {
            StackTrace st = new StackTrace(e, true);
              List<StackFrame> stackFrames = new List<StackFrame>(st.GetFrames());

              // Last stack frame is always "MonoMethod.Invoke()". Remove it.
              stackFrames.RemoveAt(stackFrames.Count - 1);

              // Search for first unit testing api frame
              int index = -1;
              foreach (StackFrame sf in stackFrames) {
            MethodBase method = sf.GetMethod();
            if (method.DeclaringType.Namespace != typeof(Assert).Namespace) {
              break;
            }

            index++;
              }

              if (index != -1) {
            stackFrames.RemoveRange(0, index);
              }

              return stackFrames;
        }
开发者ID:pythe,项目名称:wristpass,代码行数:25,代码来源:TestMethodResultActivity.cs

示例14: RecursiveFilterTsumo

        // this function removes rinshan tsumo
        List<MJsonMessageAll> RecursiveFilterTsumo(List<MJsonMessageAll> msgobjList)
        {
            var lastKanIndex = msgobjList.FindIndex(e => e.IsKAKAN() || e.IsDAIMINKAN() || e.IsANKAN());

            if (lastKanIndex == -1)
            {
                return msgobjList;
            }

            var rinshanIndex = lastKanIndex + 1;
            if (rinshanIndex >= msgobjList.Count)
            {
                return msgobjList.GetRange(0, lastKanIndex);
            }
            else
            {
                msgobjList.RemoveRange(lastKanIndex, 2);
                return RecursiveFilterTsumo(msgobjList);
            }
        }
开发者ID:rick0000,项目名称:MjModel,代码行数:21,代码来源:GameRoomTests.cs

示例15: LProdExperimentZ3

        private void LProdExperimentZ3(BitWidth encoding)
        {
            List<string> regexes = new List<string>(SampleRegexes.regexes);
            regexes.RemoveRange(6, regexes.Count - 6); //just consider the first 100 cases

            int nonemptyCount = 0;

            for (int i = 0; i < regexes.Count; i++)
                for (int j = 0; j < regexes.Count; j++)
                {
                    string regexA = regexes[i];
                    string regexB = regexes[j];

                    var z3p = new Z3Provider(encoding);

                    z3p.MainSolver.Push();

                    var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
                    var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);

                    List<Expr> witness;
                    bool C = Automaton<Expr>.CheckProduct(A, B, 0, out witness);

                    if (i == j)
                        Assert.IsTrue(C, "product must me nonempty");
                    if (C)
                    {
                        nonemptyCount += 1;
                        string s = new String(Array.ConvertAll(witness.ToArray(), cs => { return z3p.GetCharValue(z3p.MainSolver.FindOneMember(cs).Value); }));
                        Assert.IsTrue(Regex.IsMatch(s, regexA, RegexOptions.None), "regex mismatch");
                        Assert.IsTrue(Regex.IsMatch(s, regexB, RegexOptions.None), "regex mismatch");
                    }

                    z3p.MainSolver.Pop();
                }
            Assert.AreEqual<int>(10, nonemptyCount, "wrong number of empty intersections");
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:37,代码来源:FiniteAutomataTests.cs


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