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


C# List.Add方法代码示例

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


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

示例1: AccountForEfficiencies_FixedEnd_MultipleDateIntervalEfficiencies_ReturnsCorrectAnswer

        public void AccountForEfficiencies_FixedEnd_MultipleDateIntervalEfficiencies_ReturnsCorrectAnswer()
        {
            //         +------------+
            //       |0|  |0|  |0|

            // Result:
            //   +------------------+
            //       |0|  |0|  |0|

            // Arrange
            var now = DateTime.Now;
            var dateInterval = new DateInterval(now, now.AddDays(5));

            var dateIntervalEfficiencies = new List<DateIntervalEfficiency>();
            var efficiency1 = new DateIntervalEfficiency(now.AddDays(1), now.AddDays(2), 0);
            var efficiency2 = new DateIntervalEfficiency(now.AddDays(3), now.AddDays(4), 0);
            var efficiency3 = new DateIntervalEfficiency(now.AddDays(5), now.AddDays(6), 0);

            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Max);

            var correctDateInterval = new DateInterval(dateInterval.Max.Value.Add(-dateInterval.Duration).Add(-efficiency1.Duration).Add(-efficiency2.Duration).Add(-efficiency3.Duration), dateInterval.Max.Value);

            // Assert
            Assert.AreEqual(correctDateInterval, newDateInterval);
        }
开发者ID:asheze,项目名称:Orcomp,代码行数:30,代码来源:AccountForEfficienciesTest.cs

示例2: Test_Add_ListAll

        public void Test_Add_ListAll()
        {
            List<Orderline> orderlines = new List<Orderline>();
            Orderline OL1 = new Orderline() { OrderId = 2, MovieId = 6, Amount = 6, Price = 30 };
            Orderline Ol2 = new Orderline() { OrderId = 2, MovieId = 17, Amount = 8, Price = 30 };
            orderlines.Add(Ol2);
            orderlines.Add(OL1);
            CustomerRepository custrepo = new CustomerRepository();

            Customer cust = custrepo.Get(3);
            Status stat = new Status() { Id = 1, Name = "Shipped" };
            Order ord = new Order() { Id = 2, Orderlines = orderlines, Customer = cust, OrderDate = DateTime.Now.Date, Status = stat };

            ord.Id = 2;
            ord.Orderlines = orderlines;
            ord.Customer = cust;
            ord.OrderDate = DateTime.Now.Date;
            ord.Status = stat;

            OrderRepository ordrepo= new OrderRepository();
            int numberOfOrders = ordrepo.GetAll().Count();

            Order result1 = ordrepo.Add(ord);
            Assert.NotNull(result1);

            Order result2 = ordrepo.Get(result1.Id);
            Assert.NotNull(result2);
            Assert.AreEqual(result1.Id, result2.Id);

            int finalNumberOfOrders = ordrepo.GetAll().Count();
            Assert.AreEqual(numberOfOrders + 1, finalNumberOfOrders);
        }
开发者ID:Xorthos,项目名称:MovieStoreAssignment,代码行数:32,代码来源:OrderRepositoryTest.cs

示例3: WithSelf

            public void WithSelf()
            {
                var source = new WithSelf();
                var propertyChanges = new List<string>();
                var changes = new List<EventArgs>();
                var expectedChanges = new List<EventArgs>();

                using (var tracker = Track.Changes(source, ReferenceHandling.Structural))
                {
                    tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
                    tracker.Changed += (_, e) => changes.Add(e);
                    Assert.AreEqual(0, tracker.Changes);
                    CollectionAssert.IsEmpty(propertyChanges);
                    CollectionAssert.IsEmpty(changes);

                    source.Value = source;
                    Assert.AreEqual(1, tracker.Changes);
                    CollectionAssert.AreEqual(new[] { "Changes" }, propertyChanges);
                    expectedChanges.Add(RootChangeEventArgs.Create(ChangeTrackerNode.GetOrCreate(source, tracker.Settings, false).Value, new PropertyChangeEventArgs(source, source.GetProperty(nameof(source.Value)))));
                    CollectionAssert.AreEqual(expectedChanges, changes, EventArgsComparer.Default);

                    source.Name += "abc";
                    Assert.AreEqual(2, tracker.Changes);
                    CollectionAssert.AreEqual(new[] { "Changes", "Changes" }, propertyChanges);
                    expectedChanges.Add(RootChangeEventArgs.Create(ChangeTrackerNode.GetOrCreate(source, tracker.Settings, false).Value, new PropertyChangeEventArgs(source, source.GetProperty(nameof(source.Name)))));
                    CollectionAssert.AreEqual(expectedChanges, changes, EventArgsComparer.Default);
                }
            }
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:28,代码来源:ChangeTrackerTests.ReferenceLoops.cs

示例4: CreatesASingleProjectWhenOnlyBranches

        public void CreatesASingleProjectWhenOnlyBranches()
        {
            var mockTranslator = new Mock<ISQKeyTranslator>();
            var mockRest = new Mock<ISonarRestService>();
            var mockLogger = new Mock<INotificationManager>();
            var mockConfiguration = new Mock<IConfigurationHelper>();
            var mockPlugin = new Mock<IPluginManager>();
            var mockSourceProvider = new Mock<ISourceControlProvider>();
            var mockVsHelper = new Mock<IVsEnvironmentHelper>();

            mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties() { Value = "dummy" });
            var mockObj = mockConfiguration.Object;

            var brancheData = new List<Resource>();
            brancheData.Add(new Resource() { Key = "tekla.utilities:project:master", Name = "project master", BranchName = "master", IsBranch = true });
            brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true });
            brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_B", Name = "project feature_B", BranchName = "feature_B", IsBranch = true });

            mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(brancheData);
            var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object);
            associationModel.RefreshProjectList(false);
            Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(1));
            Assert.That(associationModel.AvailableProjects[0].BranchResources.Count, Is.EqualTo(3));
            Assert.That(associationModel.AvailableProjects[0].Name, Is.EqualTo("project"));
            Assert.That(associationModel.AvailableProjects[0].BranchResources[0].BranchName, Is.EqualTo("master"));
            Assert.That(associationModel.AvailableProjects[0].BranchResources[1].BranchName, Is.EqualTo("feature_A"));
            Assert.That(associationModel.AvailableProjects[0].BranchResources[2].BranchName, Is.EqualTo("feature_B"));
        }
开发者ID:TrimbleSolutionsCorporation,项目名称:VSSonarQubeExtension,代码行数:28,代码来源:SonarQubeViewModelTests.cs

示例5: Equals

        public void Equals()
        {
            string program = TestUtil.TypeMemberParse("public string Sentence(string title , string text);");
            CompilationUnit cu = TestUtil.ParseProgram(program);

            NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];
            TypeDeclaration ty = (TypeDeclaration) ns.Children[0];
            MethodDeclaration pgMethod = (MethodDeclaration) ty.Children[0];
            ParameterDeclarationExpression p1 = new ParameterDeclarationExpression(new TypeReference("string"), "title");
            p1.TypeReference.RankSpecifier = new int[] {};
            ParameterDeclarationExpression p2 = new ParameterDeclarationExpression(new TypeReference("string"), "text");
            p2.TypeReference.RankSpecifier = new int[] {};
            List<ParameterDeclarationExpression> argList = new List<ParameterDeclarationExpression>();
            argList.Add(p1);
            argList.Add(p2);
            MethodDeclaration exMethod = new MethodDeclaration("Sentence",
                                                               Modifiers.Public,
                                                               new TypeReference("string"),
                                                               argList, null);

            Assert.IsTrue(Equals(exMethod, pgMethod));

            string program2 = TestUtil.TypeMemberParse("public string Sentence(string title , string[] text);");
            cu = TestUtil.ParseProgram(program2);

            ns = (NamespaceDeclaration) cu.Children[0];
            ty = (TypeDeclaration) ns.Children[0];
            pgMethod = (MethodDeclaration) ty.Children[0];
            Assert.IsFalse(Equals(exMethod, pgMethod));
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:30,代码来源:MethodRelatedTransformerTest.cs

示例6: CanBeUsedByLinqSetOperatorsSuchAsIntersect

        public void CanBeUsedByLinqSetOperatorsSuchAsIntersect()
        {
            IList<ConcreteEntityWithDomainSignatureProperties> objects1 =
                new List<ConcreteEntityWithDomainSignatureProperties>();
            var object1 = new ConcreteEntityWithDomainSignatureProperties { Name = "Billy McCafferty", };
            EntityIdSetter.SetIdOf(object1, 2);
            objects1.Add(object1);

            IList<ConcreteEntityWithDomainSignatureProperties> objects2 =
                new List<ConcreteEntityWithDomainSignatureProperties>();
            var object2 = new ConcreteEntityWithDomainSignatureProperties { Name = "Jimi Hendrix", };
            EntityIdSetter.SetIdOf(object2, 1);
            objects2.Add(object2);
            var object3 = new ConcreteEntityWithDomainSignatureProperties
                {
                    Name =
                        "Doesn't Matter since the Id will match and the presedence of the domain signature will go overridden", 
                };
            EntityIdSetter.SetIdOf(object3, 2);
            objects2.Add(object3);

            Assert.That(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).Count(), 
                Is.EqualTo(1));
            Assert.AreEqual(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).First(), 
                object1);
            Assert.AreEqual(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).First(), 
                object3);
        }
开发者ID:Ziack,项目名称:Go2.Architecture,代码行数:34,代码来源:BaseObjectEqualityComparerTests.cs

示例7: task1_copyAssessmentFiles

        // PHASE 1 - TASKS
    	        
        public void task1_copyAssessmentFiles(IAnalysisArtifacts analysisArtifacts)
        {        
            if (deletePhase1FolderBeforeCopying)
                Files.deleteAllFilesFromDir(folderWithArtifacts_Phase1);
                
            var filesCopied = new List<string>();
            foreach(var fileOrFolder in analysisArtifacts.assessmentFilesOrFolderToLoad)
            {        		
                if (File.Exists(fileOrFolder))
                    filesCopied.Add(Files.CopyVerbose(fileOrFolder, folderWithArtifacts_Phase1,dontCopyIfTargetFileAlreadyExists));
                else 
                    if (Directory.Exists(fileOrFolder))        		        			
                        foreach(var assessmentFile in Files.getFilesFromDir_returnFullPath(fileOrFolder, "*.ozasmt", true))
                            filesCopied.Add(Files.CopyVerbose(assessmentFile, folderWithArtifacts_Phase1,dontCopyIfTargetFileAlreadyExists));
            }

  			            
            //check to see if files were copied  ok
            foreach(var file in  filesCopied)
            {
                var fileName = Path.GetFileName(file);
                var targetFolder = folderWithArtifacts_Phase1;
                var expectedFile = Path.Combine(targetFolder, fileName);
                Assert.That(File.Exists(expectedFile),"Expected file did not exist " + expectedFile);
            }
        }
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Scripts,代码行数:28,代码来源:Analysis_WorkFlow_Phase_1.cs

示例8: GetLibrariesToPreload

 protected override void GetLibrariesToPreload(List<string> libraries)
 {
     libraries.Add("VMDataBridge.dll");
     libraries.Add("DSCoreNodes.dll");
     libraries.Add("DSIronPython.dll");
     base.GetLibrariesToPreload(libraries);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:7,代码来源:UnicodeTest.cs

示例9: Run

        public void Run(string[] args, string sourceFile, string targetFile, bool checkOutput)
        {
            // console programs' Main are static, so lock concurrent access to
            // a test code. we use a private field to lock upon

            lock (locked)
            {
                List<string> completeArgs = new List<string>(args.Length + 2);

                for (int i = 0; i < args.Length; ++i)
                    completeArgs.Add(args[i]);

                completeArgs.Add(sourceFile);
                completeArgs.Add(targetFile);

                File.Delete(targetFile);

                BitMiracle.TiffCP.Program.Main(completeArgs.ToArray());

                string sampleFile = targetFile.Replace(@"\Output.Tiff\", @"\Expected.Tiff\");
                Assert.IsTrue(File.Exists(targetFile));

                if (checkOutput)
                    FileAssert.AreEqual(sampleFile, targetFile);
            }
        }
开发者ID:Core-Techs,项目名称:TiffLibrary,代码行数:26,代码来源:Tester.cs

示例10: AvailabilityValueWritesAvailabilityProperty

        public void AvailabilityValueWritesAvailabilityProperty()
        {
            JulianDate start = new JulianDate(new GregorianDate(2012, 4, 2, 1, 2, 3));
            JulianDate stop = new JulianDate(new GregorianDate(2012, 4, 3, 1, 2, 3));

            m_output.WriteStartSequence();
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                packet.WriteAvailability(start, stop);
            }
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                packet.WriteAvailability(new TimeInterval(start, stop));
            }
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                var intervals = new List<TimeInterval>();
                intervals.Add(new TimeInterval(start, stop));
                intervals.Add(new TimeInterval(start.AddDays(2.0), stop.AddDays(2.0)));
                packet.WriteAvailability(intervals);
            }
            m_output.WriteEndSequence();

            Assert.AreEqual("[{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                            "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                            "{\"availability\":[\"20120402T010203Z/20120403T010203Z\",\"20120404T010203Z/20120405T010203Z\"]}]",
                            m_sw.ToString());
        }
开发者ID:hanokhaloni,项目名称:czml-writer,代码行数:28,代码来源:TestCesiumPacketWriter.cs

示例11: TestExploit

        public void TestExploit()
        {
            List<string> files = new List<string>();

            files.Add(@"C:\Dev\hMailServer\exploit\CREATE.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\APPEND.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\EXAMINE.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\LIST1.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\LIST2.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\LSUB.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\RENAME1.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\RENAME2.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\SEARCH.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\SELECT.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\STATUS.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\SUBSCRIBE.txt");
            files.Add(@"C:\Dev\hMailServer\exploit\UNSUBSCRIBE.txt");

            foreach (string file in files)
            {
                SendExploitFile(file, false);
            }

            foreach (string file in files)
            {
                SendExploitFile(file, true);
            }
        }
开发者ID:nberardi,项目名称:hMailServer,代码行数:28,代码来源:Program.cs

示例12: Constructor_Exceptions

		public void Constructor_Exceptions ()
		{
			HostFileChangeMonitor monitor;
			string relPath = Path.Combine ("relative", "file", "path");
			var paths = new List<string> {
				relPath
			};

			AssertExtensions.Throws<ArgumentException> (() => {
				monitor = new HostFileChangeMonitor (paths);
			}, "#A1");

			paths.Clear ();
			paths.Add (null);
			AssertExtensions.Throws<ArgumentException> (() => {
				monitor = new HostFileChangeMonitor (paths);
			}, "#A2");

			paths.Clear ();
			paths.Add (String.Empty);
			AssertExtensions.Throws<ArgumentException> (() => {
				monitor = new HostFileChangeMonitor (paths);
			}, "#A3");

			AssertExtensions.Throws<ArgumentNullException> (() => {
				monitor = new HostFileChangeMonitor (null);
			}, "#A4");

			paths.Clear ();
			AssertExtensions.Throws<ArgumentException> (() => {
				monitor = new HostFileChangeMonitor (paths);
			}, "#A5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:33,代码来源:HostFileChangeMonitorTest.cs

示例13: CreatePassportProjectToFileWithToTest

        public void CreatePassportProjectToFileWithToTest()
        {
            var pathFileSave = Path.Combine(Path.GetTempPath(), "UPPY" + Environment.TickCount + ".tmp");
            var list = new List<HierarchyNumberDrawing>();
            list.Add(new HierarchyNumberDrawing() { HierarchyNumber = "1.", TechRouteId = 2 });
            list.Add(new HierarchyNumberDrawing() { HierarchyNumber = "1.1.", TechRouteId = 4 });
            list.Add(new HierarchyNumberDrawing() { HierarchyNumber = "2.", });// TechRouteId = 1
            list.Add(new HierarchyNumberDrawing() { HierarchyNumber = "3.", TechRouteId = 3 });
            list.Add(new HierarchyNumberDrawing() { HierarchyNumber = "4.", TechRouteId = 5 });

            var listTo = new List<TechOperation>();
            listTo.Add(new TechOperation() { Id = 1, ShortName = "A" });
            listTo.Add(new TechOperation() { Id = 2, ShortName = "B" });
            listTo.Add(new TechOperation() { Id = 3, ShortName = "C" });
            listTo.Add(new TechOperation() { Id = 4, ShortName = "D" });
            listTo.Add(new TechOperation() { Id = 5, ShortName = "E" });

            var listTr = new List<TechRoute>();
            listTr.Add(new TechRoute() { Id = 1, TechOperations = new List<TechOperation>() { new TechOperation() { Id = 1 }, new TechOperation() { Id = 2 } } });
            listTr.Add(new TechRoute() { Id = 2, TechOperations = new List<TechOperation>() { new TechOperation() { Id = 2 }, new TechOperation() { Id = 3 } } });
            listTr.Add(new TechRoute() { Id = 3, TechOperations = new List<TechOperation>() { new TechOperation() { Id = 3 }, new TechOperation() { Id = 5 } } });
            listTr.Add(new TechRoute() { Id = 4, TechOperations = new List<TechOperation>() { new TechOperation() { Id = 1 }, new TechOperation() { Id = 2 }, new TechOperation() { Id = 4 } } });
            listTr.Add(new TechRoute() { Id = 5, TechOperations = new List<TechOperation>() { new TechOperation() { Id = 5 } } });

            var header = new Order();

            ExportExcelFile excelFile = new ExportExcelFile();

            Debug.WriteLine(pathFileSave);

            Assert.DoesNotThrow(() =>
            {
                excelFile.CreatePassportProjectToFile(header, list, listTo, listTr, pathFileSave);
            });
        }
开发者ID:ctukc-nt,项目名称:UPPY,代码行数:35,代码来源:ExportExcelFileTests.cs

示例14: Test

		public void Test()
		{
			var CustomThreadPool = new CustomThreadPool(2);
			var Results0 = new List<int>();
			var Results1 = new List<int>();
			var CountdownEvent = new CountdownEvent(2);

			CustomThreadPool.AddTask(0, () =>
			{
				Thread.Sleep(10);
				Results0.Add(0);
			});
			CustomThreadPool.AddTask(0, () =>
			{
				Results0.Add(1);
				CountdownEvent.Signal();
			});
			CustomThreadPool.AddTask(1, () =>
			{
				Results1.Add(0);
				CountdownEvent.Signal();
			});

			CountdownEvent.Wait();
			Thread.Sleep(10);
			Assert.IsTrue(CustomThreadPool.GetLoopIterCount(0) <= 2);
			Assert.IsTrue(CustomThreadPool.GetLoopIterCount(1) <= 2);
			Assert.AreEqual("0,1", Results0.ToStringArray());
			Assert.AreEqual("0", Results1.ToStringArray());
			CustomThreadPool.Stop();
		}
开发者ID:sweetwxh,项目名称:csharputils,代码行数:31,代码来源:CustomThreadPoolTest.cs

示例15: GetsCorrectVictor

        public int GetsCorrectVictor(Pick p1, Pick p2)
        {
            List<IPlayer> players = new List<IPlayer>();
            IPlayer player1 = Substitute.For<IPlayer>();
            player1.Pick.Returns(p1);
            player1.Slot.Returns(1);
            players.Add(player1);
            IPlayer player2 = Substitute.For<IPlayer>();
            player2.Pick.Returns(p2);
            player2.Slot.Returns(2);

            players.Add(player2);

            var game = new Game(players);

            var gameResult = Result.None;
            var victor = -1;

            game.GameEnds = (result, i) =>
            {
                gameResult = result;
                victor = i;
            };

            game.StartGame();
            Thread.Sleep(100);
            Assert.AreEqual(Result.Victory, gameResult);

            return victor;
        }
开发者ID:gitanamoBay,项目名称:loquacious-guacamole,代码行数:30,代码来源:GameTests.cs


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