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


C# List.Add方法代码示例

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


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

示例1: CompileFile

        public static CompilerResults CompileFile(string input, string output, params string[] references)
        {
            CreateOutput(output);

            List<string> referencedAssemblies = new List<string>(references.Length + 3);

            referencedAssemblies.AddRange(references);
            referencedAssemblies.Add("System.dll");
            referencedAssemblies.Add(typeof(IModule).Assembly.CodeBase.Replace(@"file:///", ""));
            referencedAssemblies.Add(typeof(ModuleAttribute).Assembly.CodeBase.Replace(@"file:///", ""));

            CSharpCodeProvider codeProvider = new CSharpCodeProvider();
            CompilerParameters cp = new CompilerParameters(referencedAssemblies.ToArray(), output);

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(input))
            {
                if (stream == null)
                {
                    throw new ArgumentException("input");
                }

                StreamReader reader = new StreamReader(stream);
                string source = reader.ReadToEnd();
                CompilerResults results = codeProvider.CompileAssemblyFromSource(cp, source);
                ThrowIfCompilerError(results);
                return results;
            }
        }
开发者ID:eslahi,项目名称:prism,代码行数:28,代码来源:CompilerHelper.Desktop.cs

示例2: TestLoadAndRunDynamic

        public void TestLoadAndRunDynamic()
        {

            var cities = new Cities();
            cities.ReadCities(CitiesTestFile);

            IRoutes routes = RoutesFactory.Create(cities);

            routes.ReadRoutes(LinksTestFile);

            Assert.AreEqual(11, cities.Count);

            // test available cities
            List<Link> links = routes.FindShortestRouteBetween("Zürich", "Basel", TransportModes.Rail);

            var expectedLinks = new List<Link>();
            expectedLinks.Add(new Link(new City("Zürich", "Switzerland", 7000, 1, 2),
                                       new City("Aarau", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Aarau", "Switzerland", 7000, 1, 2),
                                       new City("Liestal", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Liestal", "Switzerland", 7000, 1, 2),
                                       new City("Basel", "Switzerland", 7000, 1, 2), 0));

            Assert.IsNotNull(links);
            Assert.AreEqual(expectedLinks.Count, links.Count);

            for (int i = 0; i < links.Count; i++)
            {
                Assert.AreEqual(expectedLinks[i].FromCity.Name, links[i].FromCity.Name);
                Assert.AreEqual(expectedLinks[i].ToCity.Name, links[i].ToCity.Name);
            }

            links = routes.FindShortestRouteBetween("doesNotExist", "either", TransportModes.Rail);
            Assert.IsNull(links);
        }
开发者ID:mjenny,项目名称:ECNF,代码行数:35,代码来源:Lab5Test.cs

示例3: 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[((int)FILL_ME_IN)], "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)FILL_ME_IN }), dynamicArray.ToArray(), "Identify all of the elements in the array");
        }
开发者ID:PhotoNomad0,项目名称:csharp-koans,代码行数:28,代码来源:AboutArrays.cs

示例4: InsertAll_InsertItems_WithTypeHierarchyBase

        public void InsertAll_InsertItems_WithTypeHierarchyBase()
        {
            using (var db = Context.Sql())
            {
                if (db.Database.Exists())
                {
                    db.Database.Delete();
                }
                db.Database.Create();

                List<Person> people = new List<Person>();
                people.Add(Person.Build("FN1", "LN1"));
                people.Add(Person.Build("FN2", "LN2"));
                people.Add(Person.Build("FN3", "LN3"));

                EFBatchOperation.For(db, db.People).InsertAll(people);
            }

            using (var db = Context.Sql())
            {
                var contacts = db.People.OrderBy(c => c.FirstName).ToList();
                Assert.AreEqual(3, contacts.Count);
                Assert.AreEqual("FN1", contacts.First().FirstName);
            }
        }
开发者ID:ArthurYiL,项目名称:EntityFramework.Utilities,代码行数:25,代码来源:InsertTests.cs

示例5: LifeCycleCycleTestBlinker

        public void LifeCycleCycleTestBlinker()
        {
            List<Cell> blinkerTextCellsVertical = new List<Cell>();
            blinkerTextCellsVertical.Add(new Cell(2, 1));
            blinkerTextCellsVertical.Add(new Cell(2, 2));
            blinkerTextCellsVertical.Add(new Cell(2, 3));

            LifeCycle lifeCycle = new LifeCycle(blinkerTextCellsVertical);

            lifeCycle.Cycle();

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(3, 2)));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3)));
            Assert.IsTrue(lifeCycle.Cells.Count == 3);

            lifeCycle.Cycle();

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 1)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3)));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2)));
            Assert.IsTrue(lifeCycle.Cells.Count == 3);
        }
开发者ID:bradwalbeck,项目名称:ConwaysGameOfLife,代码行数:27,代码来源:LifeCycleTest.cs

示例6: DuplicateActivations

        public void DuplicateActivations()
        {
            const int nRunnerGrains = 100;
            const int nTargetGRain = 10;
            const int startingKey = 1000;
            const int nCallsToEach = 100;

            var runnerGrains = new ICatalogTestGrain[nRunnerGrains];

            var promises = new List<Task>();
            for (int i = 0; i < nRunnerGrains; i++)
            {
                runnerGrains[i] = GrainClient.GrainFactory.GetGrain<ICatalogTestGrain>(i.ToString(CultureInfo.InvariantCulture));
                promises.Add(runnerGrains[i].Initialize());
            }

            Task.WhenAll(promises).Wait();
            promises.Clear();

            for (int i = 0; i < nRunnerGrains; i++)
            {
                promises.Add(runnerGrains[i].BlastCallNewGrains(nTargetGRain, startingKey, nCallsToEach));
            }

            Task.WhenAll(promises).Wait();
        }
开发者ID:fgq841103,项目名称:orleans,代码行数:26,代码来源:DuplicateActivationsTests.cs

示例7: CollisionComparison

        public void CollisionComparison()
        {
            CollisionDictionary d = new CollisionDictionary();
            List<PhysicalObject2D> allSprites = new List<PhysicalObject2D>();

            for (int i=0; i<1000000; i++)
            {
                Sprite s = new Sprite(this, "blocky");
                s.Size = new Vector2(10);
                s.Position = i * s.Size;

                d.Add(s.Bounds);
                allSprites.Add(s);
            }

            Sprite firstSprite = new Sprite(this, "blocky");
            firstSprite.Size = new Vector2(50);
            firstSprite.Position = new Vector2(300);

            allSprites.Add(firstSprite);

            Stopwatch sw = Stopwatch.StartNew();
            DoConventionalCollisionCheck(firstSprite, allSprites);
            Console.WriteLine(sw.ElapsedMilliseconds);

            sw = Stopwatch.StartNew();
            d.CalculateCollisions(firstSprite.Bounds);
            Console.WriteLine(sw.ElapsedMilliseconds);
        }
开发者ID:steynh,项目名称:GamingMinor,代码行数:29,代码来源:CollisionTests.cs

示例8: MakeDeepCopies

        internal static void MakeDeepCopies(List<ModelHelperInfo> modelHelperInfos, int cCopies, string directory)
        {
            int cModels = modelHelperInfos.Count;

            for (int iCopy = 0; iCopy < cCopies - 1; iCopy++)
            {
                for (int iModel = 0; iModel < cModels; iModel++)
                {
                    ModelHelperInfo modelHelperInfo = modelHelperInfos[iModel];
                    ModelHelperInfo modelHelperInfoCopy = ModelHelperInfo.Create(directory);

                    foreach (DeploymentModelStepsStep step in modelHelperInfo.modelHelper.AllSteps)
                    {
                        List<string> commandParamStrings = new List<string>();
                        for (int iCommandParam = 0; iCommandParam < step.CommandParam.Length; iCommandParam++)
                        {
                            commandParamStrings.Add(step.CommandParam[iCommandParam].Name);
                            commandParamStrings.Add(step.CommandParam[iCommandParam].ParameterName);
                        }

                        modelHelperInfoCopy.modelHelper.AddStep(step.Type, step.Command, step.Message, commandParamStrings.ToArray());
                    }

                    IEnumerable<DeploymentModelParametersParameter> dmParams = modelHelperInfo.modelHelper.AllParameters;
                    foreach (DeploymentModelParametersParameter dmParam in dmParams)
                    {
                        modelHelperInfoCopy.modelHelper.AddParameter(dmParam.Name, dmParam.Value, dmParam.Required, dmParam.ValuePrefixRef, dmParam.ValueSuffix);
                    }

                    modelHelperInfos.Add(modelHelperInfoCopy);
                }
            }
        }
开发者ID:nazik,项目名称:inst4wa,代码行数:33,代码来源:UnitTest1.cs

示例9: GetEnderecos

        public static List<Endereco> GetEnderecos()
        {
            List<Endereco> enderecos = new List<Endereco>();

            Pessoa pessoa = new Pessoa();
            pessoa.Nome = "Bruno3";

            pessoa.DataNascimento = new DateTime(1995, 06, 01, 0, 0, 0);
            pessoa.Cpf = "0911095678";
            pessoa.Profissao = "Tester";

            Endereco endereco1 = new Endereco();
            endereco1.Rua = "João";
            endereco1.Numero = 98;
            endereco1.Cep = "0911095679";
            endereco1.Cidade = "Lages";
            endereco1.Pessoa = pessoa;

            Endereco endereco2 = new Endereco();
            endereco2.Rua = "João";
            endereco2.Numero = 98;
            endereco2.Cep = "0911095679";
            endereco2.Cidade = "Lages";
            endereco2.Pessoa = pessoa;

            enderecos.Add(endereco1);
            enderecos.Add(endereco2);

            return enderecos;
        }
开发者ID:BrunoExterckotter,项目名称:Trabalho,代码行数:30,代码来源:ObjectMother.cs

示例10: FindPeaksTest

        public void FindPeaksTest()
        {
            Bitmap hand = Properties.Resources.rhand;

            GaussianBlur median = new GaussianBlur(1.1);
            median.ApplyInPlace(hand);

            // Extract contour
            BorderFollowing bf = new BorderFollowing(1);
            List<IntPoint> contour = bf.FindContour(hand);

            hand = hand.Clone(new Rectangle(0, 0, hand.Width, hand.Height), PixelFormat.Format24bppRgb);

            // Find peaks
            KCurvature kcurv = new KCurvature(30, new DoubleRange(0, 45));
            // kcurv.Suppression = 30;
            var peaks = kcurv.FindPeaks(contour);

            List<IntPoint> supports = new List<IntPoint>();
            for (int i = 0; i < peaks.Count; i++)
            {
                int j = contour.IndexOf(peaks[i]);
                supports.Add(contour[(j + kcurv.K) % contour.Count]);
                supports.Add(contour[Accord.Math.Tools.Mod(j - kcurv.K, contour.Count)]);
            }

            // show(hand, contour, peaks, supports);

            Assert.AreEqual(2, peaks.Count);
            Assert.AreEqual(46, peaks[0].X);
            Assert.AreEqual(0, peaks[0].Y);
            Assert.AreEqual(2, peaks[1].X);
            Assert.AreEqual(11, peaks[1].Y);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:34,代码来源:KCurvatureTest.cs

示例11: Test1Test

		public void Test1Test()
		{
			var Values = new List<int>();

			var Thread1 = new GreenThread();
			var Thread2 = new GreenThread();
			Thread1.InitAndStartStopped(() =>
			{
				Values.Add(1);
				GreenThread.Yield();
				Values.Add(3);
			});
			Thread2.InitAndStartStopped(() =>
			{
				Values.Add(2);
				GreenThread.Yield();
				Values.Add(4);
			});

			Thread.Sleep(20);
			// Inits stopped.
			Assert.AreEqual("[]", Values.ToJson());
			Thread1.SwitchTo();
			Assert.AreEqual("[1]", Values.ToJson());
			Thread2.SwitchTo();
			Assert.AreEqual("[1,2]", Values.ToJson());
			Thread.Sleep(20);
			Thread1.SwitchTo();
			Assert.AreEqual("[1,2,3]", Values.ToJson());
			Thread2.SwitchTo();
			Assert.AreEqual("[1,2,3,4]", Values.ToJson());
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:32,代码来源:GreenThreadTest.cs

示例12: TestExcelExport

        public void TestExcelExport()
        {
            string excelFileName = Directory.GetCurrentDirectory() + @"\ExportTest.xlsx";

            City bern = new City("Bern", "Switzerland", 5000, 46.95, 7.44);
            City zuerich = new City("Zürich", "Switzerland", 100000, 32.876174, 13.187507);
            City aarau = new City("Aarau", "Switzerland", 10000, 35.876174, 12.187507);
            Link link1 = new Link(bern, aarau, 15, TransportModes.Ship);
            Link link2 = new Link(aarau, zuerich, 20, TransportModes.Ship);
            List<Link> links = new List<Link>();
            links.Add(link1);
            links.Add(link2);

            // TODO: Fix starting Excel on sever (not robust)
            ExcelExchange excel = new ExcelExchange();

            Console.WriteLine("Export Path is: {0}", excelFileName);

            excel.WriteToFile(excelFileName, bern, zuerich, links);

            // first verify that file exists
            Assert.IsTrue(File.Exists(excelFileName));

            // now verify the content of the file
            // TODO: Fix reading file on sever
            VerifyExcelContent(excelFileName);
        }
开发者ID:platzhersh,项目名称:FHNW-Java-Projekte,代码行数:27,代码来源:Lab7Test.cs

示例13: TestMethod1

        public void TestMethod1()
        {
            List<KeyValuePair<string, string>> mongoEnv = new List<KeyValuePair<string, string>>();

            mongoEnv.Add(new KeyValuePair<string, string>("MongoServer", "localhost"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoPort", "27017"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoRepositorySvcConfig", "ServiceConfig"));

            ServiceComponentProvider scp = new ServiceComponentProvider(mongoEnv);
            ServiceComponent sc = new ServiceComponent()
            {
                Assembly = "theAssembly",
                Class = "theClass",
                CommandMessageQueue = "theQueue",
                Config = "theConfig",
                CreateDate = DateTime.UtcNow,
                Creator = string.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName),
                IsActive = false,
                IsPaused = false,
                Machine = Environment.MachineName,
                ParamsAssembly = "paramsAssembly",
                ParamsClass = "paramsClass"
            };

            Guid origId = sc.Id;

            scp.Insert(sc);

            ServiceComponent sc2 = scp.Queryable().Single(x => x.Id == origId);

            Assert.AreEqual<Guid>(origId, sc2.Id);

            scp.Delete(sc2);
        }
开发者ID:dkearney1,项目名称:Default,代码行数:34,代码来源:ServiceComponentTests.cs

示例14: DeadlockDetection_2

        public async Task DeadlockDetection_2()
        {
            long bBase = 100;
            for (int i = 0; i < numIterations; i++)
            {
                long grainId = i;
                IDeadlockNonReentrantGrain firstGrain = GrainClient.GrainFactory.GetGrain<IDeadlockNonReentrantGrain>(grainId);
                List<Tuple<long, bool>> callChain = new List<Tuple<long, bool>>();
                callChain.Add(new Tuple<long, bool>(grainId, true));
                callChain.Add(new Tuple<long, bool>(bBase + grainId, true));
                callChain.Add(new Tuple<long, bool>(grainId, true));

                try
                {
                    await firstGrain.CallNext_1(callChain, 1);
                }
                catch (Exception exc)
                {
                    Exception baseExc = exc.GetBaseException();
                    logger.Info(baseExc.Message);
                    Assert.AreEqual(typeof(DeadlockException), baseExc.GetType());
                    DeadlockException deadlockExc = (DeadlockException)baseExc;
                    Assert.AreEqual(callChain.Count, deadlockExc.CallChain.Count());
                }
            }
        }
开发者ID:fgq841103,项目名称:orleans,代码行数:26,代码来源:DeadlockDetectionTests.cs

示例15: GetAggregatedValueTest

        public void GetAggregatedValueTest()
        {
            var cell1 = new Mock<Cell>();
            var cell2 = new Mock<Cell>();
            var cell3 = new Mock<Cell>();
            var cell4 = new Mock<Cell>();
            cell1.Setup(foo => foo.Content).Returns((double)0.6);
            cell2.Setup(foo => foo.Content).Returns((double)3);
            cell3.Setup(foo => foo.Content).Returns((double)0.3);
            cell4.Setup(foo => foo.Content).Returns((double)0.1);
            List<Cell> cells = new List<Cell>();
            cells.Add(cell1.Object);
            cells.Add(cell2.Object);
            cells.Add(cell3.Object);
            MinAggregation target = new MinAggregation();
            double expected = 0.3;
            double actual;
            actual = (double)target.GetAggregatedValue(cells);
            Assert.AreEqual(expected, actual);

            cells.Add(cell4.Object);
            expected = 0.1;
            actual = (double)target.GetAggregatedValue(cells);
            Assert.AreEqual(expected, actual);
        }
开发者ID:patrykkurczyna,项目名称:Unified-Data-Model,代码行数:25,代码来源:MinAggregationTest.cs


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