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


C# List.TrueForAll方法代码示例

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


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

示例1: AssertFirstMove

 protected void AssertFirstMove(string expected, List<List<MoveDesc>> actual)
 {
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual.Count > 0);
     Assert.IsTrue(actual.TrueForAll(x => x.Count > 0));
     actual.ForEach(x => Assert.AreEqual(expected, x[0].ToString(
         Notation.LongAlgebraic)));
 }
开发者ID:maksimbulva,项目名称:chesshive,代码行数:8,代码来源:EngineTestBase.cs

示例2: TestHandToStringMethod

        public void TestHandToStringMethod()
        {
            var rndNumber = new Random();
            var listOfCards = new List<ICard>();

            for (int i = 0; i < 5; i++)
            {
                CardFace rndCardFace = (CardFace)rndNumber.Next(2, 15);
                CardSuit rndCardSuit = (CardSuit)rndNumber.Next(1, 5);

                listOfCards.Add(new Card(rndCardFace, rndCardSuit));
            }
            Hand randomHand = new Hand(listOfCards);
            Assert.IsTrue(listOfCards.TrueForAll(x => randomHand.ToString().IndexOf(x.ToString()) > 0));
        }
开发者ID:Boyan1912,项目名称:Quality-Program-Code,代码行数:15,代码来源:TestPoker.cs

示例3: TestBachingPostPointsAsync

        public async Task TestBachingPostPointsAsync()
        {
            try
            {
                var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);

                var points = new List<IInfluxDatapoint> ();

                var today = DateTime.Now.ToShortDateString ();
                var now = DateTime.Now.ToShortTimeString ();
                var start = DateTime.Now.AddDays (-5);
                var end = DateTime.Now;

                for ( int i = 0; i < 5000; i++ )
                {
                    var valDouble = new InfluxDatapoint<double> ();
                    valDouble.UtcTimestamp = DataGen.RandomDate (start, end);
                    valDouble.Tags.Add ("TestDate", today);
                    valDouble.Tags.Add ("TestTime", now);
                    valDouble.Fields.Add ("Doublefield", DataGen.RandomDouble ());
                    valDouble.Fields.Add ("Doublefield2", DataGen.RandomDouble ());
                    valDouble.MeasurementName = measurementName;
                    valDouble.Precision = (TimePrecision) ( DataGen.RandomInt () % 6 ) + 1;

                    var valInt = new InfluxDatapoint<int> ();
                    valInt.UtcTimestamp = DataGen.RandomDate (start, end);
                    valInt.Tags.Add ("TestDate", today);
                    valInt.Tags.Add ("TestTime", now);
                    valInt.Fields.Add ("Intfield", DataGen.RandomInt ());
                    valInt.Fields.Add ("Intfield2", DataGen.RandomInt ());
                    valInt.MeasurementName = measurementName;
                    valInt.Precision = (TimePrecision) ( DataGen.RandomInt () % 6 ) + 1;

                    var valBool = new InfluxDatapoint<bool> ();
                    valBool.UtcTimestamp = DataGen.RandomDate (start, end);
                    valBool.Tags.Add ("TestDate", today);
                    valBool.Tags.Add ("TestTime", now);
                    valBool.Fields.Add ("Booleanfield", DateTime.Now.Ticks % 2 == 0);
                    valBool.MeasurementName = measurementName;
                    valBool.Precision = (TimePrecision) ( DataGen.RandomInt () % 6 ) + 1;

                    var valString = new InfluxDatapoint<string> ();
                    valString.UtcTimestamp = DataGen.RandomDate (start, end);
                    valString.Tags.Add ("TestDate", today);
                    valString.Tags.Add ("TestTime", now);
                    valString.Fields.Add ("Stringfield", DataGen.RandomString ());
                    valString.MeasurementName = measurementName;
                    valString.Precision = (TimePrecision) ( DataGen.RandomInt () % 6 ) + 1;


                    points.Add (valString);
                    points.Add (valInt);
                    points.Add (valDouble);
                    points.Add (valBool);
                }

                var r = await client.PostPointsAsync (dbName, points);
                Assert.IsTrue (points.TrueForAll (p => p.Saved == true), "PostPointsAsync did not save all points");

            }
            catch ( Exception e )
            {

                Assert.Fail ("Unexpected exception of type {0} caught: {1}",
                            e.GetType (), e.Message);
                return;
            }
        }
开发者ID:jackthorley,项目名称:InfluxDB.Client.Net,代码行数:68,代码来源:InfluxDBClientTest.cs

示例4: TestUnLink

        public void TestUnLink()
        {
            LogicContainer_Accessor target = new LogicContainer_Accessor();
            List<CounterComponent> counters = new List<CounterComponent>()
            {
                new NoneCounter(),
                new DraweableCounter(),
                new BothCounter(),
                new UpdateableCounter(),
            };

            foreach (var item in counters)
                target.Add(item);

            target.Remove(counters[0]);

            Assert.AreEqual(3, counters[0].CountRemoved);
            counters.RemoveAt(0);

            Assert.IsTrue(counters.TrueForAll(item => item.CountRemoved == 1));
        }
开发者ID:jumonb,项目名称:barebones_csharp,代码行数:21,代码来源:LogicContainerTest.cs

示例5: TransactionalStack3

        public void TransactionalStack3()
        {
            var stack = new TransactionalStack<int>();

            stack.Push(1);
            stack.Push(2);
            stack.Push(3);

            var t1 = stack.BeginTransaction();
            var t2 = stack.BeginTransaction();

            t1.Push(4);
            t2.Push(5);

            t1.Commit();
            AssertionHelpers.AssertThrows<Psimulex.Core.Exceptions.InvalidTransactionException>(() => t2.Commit());

            Assert.AreEqual(4, stack.Pop());
            Assert.AreEqual(3, stack.Pop());
            Assert.AreEqual(2, stack.Pop());
            Assert.AreEqual(1, stack.Pop());

            var transactions = new List<StackTransaction<int>>();
            for (int i = 0; i < 100; ++i)
            {
                transactions.Add(stack.BeginTransaction());
            }

            transactions[22].Push(9);
            transactions[22].Commit();

            transactions.TrueForAll(t => t.Status == TransactionStates.Invalid || t.Status == TransactionStates.Committed);
            transactions.ForEach(t => AssertionHelpers.AssertThrows<Psimulex.Core.Exceptions.InvalidTransactionException>(() => t.Commit()));
        }
开发者ID:hunpody,项目名称:psimulex,代码行数:34,代码来源:TransactionalStackTests.cs

示例6: DirectoryTree_TestWithFileSearch

 public void DirectoryTree_TestWithFileSearch()
 {
     DirectoryTree tree = new DirectoryTree(baseDirName, "file*");
     List<String> files = new List<string>();
     tree.OnFoundFile +=
         file => {
             var ff = File.OpenRead(file.FullName);
             if (FileSearch.searchInFile(ff, Encoding.UTF8.GetBytes("словоо")))
                 files.Add(file.Name);
         };
     tree.run();
     Assert.IsFalse(files.TrueForAll(x => x != file1Name));
     Assert.IsFalse(files.TrueForAll(x => x != file4Name));
     Assert.IsTrue(files.TrueForAll(x => x != file2Name));
     Assert.IsTrue(files.TrueForAll(x => x != file3Name));
 }
开发者ID:pandvik,项目名称:winFileSearch,代码行数:16,代码来源:UnitTestDirectoryTree.cs

示例7: TestLink

        public void TestLink()
        {
            LogicContainer_Accessor target = new LogicContainer_Accessor();
            List<CounterComponent> counters = new List<CounterComponent>()
            {
                new NoneCounter(),
                new DraweableCounter(),
                new BothCounter(),
                new UpdateableCounter(),
            };

            foreach (var item in counters)
                target.Add(item);

            Assert.IsTrue(counters.TrueForAll(item => item.CountAdded == 3));
        }
开发者ID:jumonb,项目名称:barebones_csharp,代码行数:16,代码来源:LogicContainerTest.cs

示例8: DirectoryTree_Test2

 public void DirectoryTree_Test2()
 {
     DirectoryTree tree = new DirectoryTree(baseDirName, "file*");
     List<String> files = new List<string>();
     tree.OnFoundFile += x => files.Add(x.Name);
     tree.run();
     Assert.IsTrue(!files.TrueForAll(x => x != file1Name));
     Assert.IsTrue(!files.TrueForAll(x => x != file2Name));
     Assert.IsTrue(!files.TrueForAll(x => x != file3Name));
     Assert.IsTrue(!files.TrueForAll(x => x != file4Name));
 }
开发者ID:pandvik,项目名称:winFileSearch,代码行数:11,代码来源:UnitTestDirectoryTree.cs

示例9: CheckInList

 private static void CheckInList(List<string> inList, List<string> expectedInList)
 {
     inList.Sort();
     expectedInList.Sort();
     Console.WriteLine(@"Znalezione pliki:");
     foreach (string znalezionyPlik in inList)
         Console.WriteLine(znalezionyPlik);
     Console.WriteLine(@"Spodziewane pliki:");
     foreach (var znalezionyPlik in expectedInList)
         Console.WriteLine(znalezionyPlik);
     Assert.IsTrue(inList.Count == expectedInList.Count && inList.TrueForAll(expectedInList.Contains),
                   "Błąd przygotowania testu: zawartość folderu testowego nie zgadza się z przewidywaną.");
 }
开发者ID:bartoszzielinski,项目名称:musesort,代码行数:13,代码来源:TestowanieSortowania.cs

示例10: CompareHookLists

 private bool CompareHookLists(List<Hook> expected, List<Hook> actual)
 {
     return
         expected == actual ||
         (expected.Count == actual.Count &&
         expected.TrueForAll(e => CompareHooks(e, actual[expected.IndexOf(e)])));
 }
开发者ID:danielrbradley,项目名称:Plywood,代码行数:7,代码来源:HooksTest.cs

示例11: QuickPulseTelemetryModuleSupportsMultipleTelemetryProcessorsForSingleConfiguration

        public void QuickPulseTelemetryModuleSupportsMultipleTelemetryProcessorsForSingleConfiguration()
        {
            // ARRANGE
            var configXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
            <ApplicationInsights xmlns=""http://schemas.microsoft.com/ApplicationInsights/2013/Settings"">
              <InstrumentationKey>some ikey</InstrumentationKey>
              <TelemetryModules>
            <Add Type=""Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector""/>
              </TelemetryModules>
              <TelemetryProcessors>
            <Add Type=""Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector""/>
              </TelemetryProcessors>
            </ApplicationInsights>";

            File.WriteAllText(this.configFilePath, configXml);

            var config = TelemetryConfiguration.Active;

            // ACT
            var telemetryProcessors = new List<IQuickPulseTelemetryProcessor>();
            const int TelemetryProcessorCount = 4;
            for (int i = 0; i < TelemetryProcessorCount; i++)
            {
                // this recreates config.TelemetryProcessors collection, and all its members are reinstantiated
                var builder = config.TelemetryProcessorChainBuilder;
                builder = builder.Use(current => new SimpleTelemetryProcessorSpy());
                builder.Build();

                telemetryProcessors.Add(config.TelemetryProcessors.OfType<QuickPulseTelemetryProcessor>().Single());
            }

            // ASSERT
            var module = TelemetryModules.Instance.Modules.OfType<QuickPulseTelemetryModule>().SingleOrDefault();
            var registeredProcessors = QuickPulseTestHelper.GetTelemetryProcessors(module);

            Assert.AreEqual(TelemetryProcessorCount + 1, registeredProcessors.Count);  // one was there after the initial configuration loading
            Assert.IsTrue(telemetryProcessors.TrueForAll(registeredProcessors.Contains));
        }
开发者ID:xornand,项目名称:ApplicationInsights-dotnet-server,代码行数:38,代码来源:QuickPulseTelemetryModuleTests.cs

示例12: DrawRasterTest

        public void DrawRasterTest()
        {
            IRasterControlView View = MockRepository.GenerateStub<IRasterControlView>();
            View.Resolution = 100;
            View.RasterWidth = 1;
            View.IsCartesian = true;
            View.BB = new Rect(0, 0, 10, 10);
            View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix();

            RasterControlModel target = new RasterControlModel(View);
            List<Point> lstpts = new List<Point>();
            List<double> lstrads = new List<double>();
            Action<Point, Point> LineDrawMethod = (p1,p2)=>lstpts.Add(p1);
            Action<double, double> EllipseDrawMethod = (r1,r2)=>lstrads.Add(r1); 
            target.DrawRaster(LineDrawMethod, EllipseDrawMethod);
            Assert.IsTrue( lstpts.TrueForAll(p=> p.X == Math.Round(p.X) &&   p.Y == Math.Round(p.Y)));
            Assert.AreEqual(0, lstrads.Count);
        }
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:18,代码来源:RasterControlModelTest.cs


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