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


C# List.GetEnumerator方法代码示例

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


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

示例1: GetKraniumAsyncTest

		public async Task GetKraniumAsyncTest()
		{
			var kraniumsMockedList = new List<KraniumEntity>
			{
				new KraniumEntity { Name = "TheKranium", IPAddress = "192.168.0.50" },
				//new Kranium { Name = "TheBackupKranium", IPAddress = "192.168.0.51" },
			}.AsQueryable();

			var mockSet = new Mock<DbSet<KraniumEntity>>();
			mockSet.As<IDbAsyncEnumerable<KraniumEntity>>()
				.Setup(m => m.GetAsyncEnumerator())
				.Returns(new TestDbAsyncEnumerator<KraniumEntity>(kraniumsMockedList.GetEnumerator()));

			mockSet.As<IQueryable<KraniumEntity>>()
				.Setup(m => m.Provider)
				.Returns(new TestDbAsyncQueryProvider<KraniumEntity>(kraniumsMockedList.Provider));

			mockSet.As<IQueryable<KraniumEntity>>().Setup(m => m.Expression).Returns(kraniumsMockedList.Expression);
			mockSet.As<IQueryable<KraniumEntity>>().Setup(m => m.ElementType).Returns(kraniumsMockedList.ElementType);
			mockSet.As<IQueryable<KraniumEntity>>().Setup(m => m.GetEnumerator()).Returns(kraniumsMockedList.GetEnumerator());

			var mockContext = new Mock<IKraniumDbContext>();
			mockContext.Setup(c => c.Kranium).Returns(mockSet.Object);

			var repository = new EfKraniumRepository { Context = mockContext.Object };
			var kranium = await repository.GetKraniumAsync();

			Assert.IsNotNull(kranium);
			Assert.AreEqual("TheKranium", kranium.Name);
			Assert.AreEqual("192.168.0.50", kranium.IPAddress);
		}
开发者ID:TheGapFillers,项目名称:Auluxa,代码行数:31,代码来源:KraniumTests.cs

示例2: should_find_the_last_third_element

            public void should_find_the_last_third_element()
            {
                var listToRead = new List<int> {1, 4, 5, 7, 9, 0, -3, 4, 6, 8};
                var target = 3;
                var pointerslow = listToRead.GetEnumerator();
                var pointerfast = listToRead.GetEnumerator();
                for(int i=0; i<target;i++)
                    pointerfast.MoveNext();
                while(pointerfast.MoveNext())
                {
                    pointerslow.MoveNext();
                }
                pointerslow.MoveNext();
                Assert.That(pointerslow.Current.Equals(4));

                var list = new MyLinkedList<int>();
                list.Insert(0);
                list.Insert(1);
                list.Insert(2);
                list.Insert(3);
                list.Insert(4);
                list.Insert(5);
                list.Insert(6);
                Assert.That(list.FindLastNthElement(3).Equals(4));
            }
开发者ID:bonniepan02,项目名称:Practice,代码行数:25,代码来源:LinkedListTest.cs

示例3: Basics

        public void Basics()
        {
            try{
            var parser = new BVE5RouteFileParser();
            var stmt = parser.ParseOneStatement(@"Sound.Load(sounds.txt);");
            var expected1 = new List<TypeDescriber>{
                TypeDescriber.Create(NodeType.Statement, new List<TypeDescriber>{
                    TypeDescriber.Create(NodeType.Invocation, new List<TypeDescriber>{
                        TypeDescriber.Create(NodeType.MemRef, new List<TypeDescriber>{
                            TypeDescriber.Create(NodeType.Identifier, null),
                            TypeDescriber.Create(NodeType.Identifier, null),
                            TypeDescriber.Create(NodeType.Identifier, null)
                        })
                    })
                })
            };
            Helpers.TestStructualEqual(expected1.GetEnumerator(), stmt);
            }
            catch(TypeLoadException e){
                var asms = AppDomain.CurrentDomain.GetAssemblies();
                foreach(var asm in asms)
                    Console.WriteLine(asm.FullName);

                Console.WriteLine(e.Message);
                Console.WriteLine(e.TypeName);
            }
        }
开发者ID:hazama-yuinyan,项目名称:monodevelop-bvebinding,代码行数:27,代码来源:Test.cs

示例4: MessageReceivedEvent

        public void MessageReceivedEvent()
        {
            ICollection<RawMessage> expectedOutput = new List<RawMessage>();

            expectedOutput.Add(new RawMessage("THEGAME", "a", "b", "cd ef g"));

            string input = string.Join("\r\n", expectedOutput.Select((message) => message.ToString()).ToArray()) + "\r\n";

            IEnumerator<RawMessage> messageChecker = expectedOutput.GetEnumerator();

            var writer = new IO.Helpers.DummyRawMessageWriter();

            using(var stringReader = new StringReader(input))
            using(var reader = new RawMessageTextReader(stringReader)) {
                using(var client = new Ondit.Client.Client(reader, writer)) {
                    client.RawMessageReceived += delegate(object sender, RawMessageEventArgs e) {
                        bool elementExists = messageChecker.MoveNext();

                        Assert.IsTrue(elementExists);
                        Assert.AreEqual(messageChecker.Current, e.Message);
                    };

                    foreach(var expectedMessage in expectedOutput) {
                        client.HandleMessage();
                    }
                }
            }
        }
开发者ID:strager,项目名称:Ondit,代码行数:28,代码来源:ClientTests.cs

示例5: SetUp

        public void SetUp()
        {
            var visits = new List<Visit>
            {
                new Visit
                {
                    Id = 1,
                    StartDate = new DateTime(2016, 11, 08, 13, 45, 56),
                    VisitType = new VisitType {Id = 1, Name = "Day Visit"}
                },
                new Visit
                {
                    Id = 2,
                    StartDate = new DateTime(2016, 11, 08, 13, 45, 56),
                    EndDate = new DateTime(2016, 11, 08, 15, 34, 10),
                    VisitType = new VisitType {Id = 1, Name = "Day Visit"}
                }
            }.AsQueryable();

            var visitSetMock = new Mock<IDbSet<Visit>>();
            visitSetMock.Setup(m => m.Provider).Returns(visits.Provider);
            visitSetMock.Setup(m => m.Expression).Returns(visits.Expression);
            visitSetMock.Setup(m => m.ElementType).Returns(visits.ElementType);
            visitSetMock.Setup(m => m.GetEnumerator()).Returns(visits.GetEnumerator());

            sitterContextMock = new Mock<SitterContext>();
            sitterContextMock.Setup(s => s.Visits).Returns(visitSetMock.Object);

            this.visitService = new VisitService(sitterContextMock.Object);
        }
开发者ID:CallumVass,项目名称:Sitter,代码行数:30,代码来源:VisitServiceTests.cs

示例6: MetaHeader

 public void MetaHeader()
 {
     var parser = new BVE5CommonParser("BveTs Station List", BVE5FileKind.StationList);
     var tree = parser.Parse(@"BveTs Station List 1.00
     staA, A, 10:00:00, 10:01:00, 20, 10:00:30, 0, 10, 0.3, soundStaA, soundStaADeperture, 0.05, 5
     ", "<string>", true);
     var expected1 = new List<TypeDescriber>{
         TypeDescriber.Create(NodeType.Tree, new List<TypeDescriber>{
             TypeDescriber.Create(NodeType.Statement, new List<TypeDescriber>{
                 TypeDescriber.Create(NodeType.Invocation, new List<TypeDescriber>{
                     TypeDescriber.Create(NodeType.Identifier, null),
                     TypeDescriber.Create(NodeType.Literal, null),		//staA
                     TypeDescriber.Create(NodeType.Literal, null),		//A
                     TypeDescriber.Create(NodeType.TimeLiteral, null),	//10:30:00
                     TypeDescriber.Create(NodeType.TimeLiteral, null),	//10:30:30
                     TypeDescriber.Create(NodeType.Literal, null),		//20
                     TypeDescriber.Create(NodeType.TimeLiteral, null),	//10:30:00
                     TypeDescriber.Create(NodeType.Literal, null),		//0
                     TypeDescriber.Create(NodeType.Literal, null),		//10
                     TypeDescriber.Create(NodeType.Literal, null),		//0.3
                     TypeDescriber.Create(NodeType.Literal, null),		//soundStaA
                     TypeDescriber.Create(NodeType.Literal, null),		//soundStaADeperture
                     TypeDescriber.Create(NodeType.Literal, null),		//0.05
                     TypeDescriber.Create(NodeType.Literal, null)		//5
                 })
             })
         })
     };
     Assert.IsFalse(parser.HasErrors);
     Helpers.TestStructualEqual(expected1.GetEnumerator(), tree);
 }
开发者ID:hazama-yuinyan,项目名称:sharpdevelop-bvebinding,代码行数:31,代码来源:ParserTest.cs

示例7: YieldsFutureDataAtCorrectTime

        public void YieldsFutureDataAtCorrectTime()
        {
            var currentTime = new DateTime(2015, 10, 13);
            var timeProvider = new ManualTimeProvider(currentTime);
            var underlying = new List<Tick>
            {
                new Tick {Time = currentTime.AddSeconds(10)}
            };

            var offsetProvider = new TimeZoneOffsetProvider(DateTimeZone.Utc, new DateTime(2015, 1, 1), new DateTime(2016, 1, 1));
            var frontierAware = new FrontierAwareEnumerator(underlying.GetEnumerator(), timeProvider, offsetProvider);

            for (int i = 0; i < 10; i++)
            {
                timeProvider.AdvanceSeconds(1);
                Assert.IsTrue(frontierAware.MoveNext());
                if (i < 9)
                {
                    Assert.IsNull(frontierAware.Current);
                }
                else
                {
                    Assert.IsNotNull(frontierAware.Current);
                    Assert.AreEqual(underlying[0], frontierAware.Current);
                }
            }
        }
开发者ID:skyfyl,项目名称:Lean,代码行数:27,代码来源:FrontierAwareEnumeratorTests.cs

示例8: T001_GetTag_Must_Fetch_Tags_From_Db_And_Return_Objects_That_Matches_Text_With_Given_Input_Tags

        public void T001_GetTag_Must_Fetch_Tags_From_Db_And_Return_Objects_That_Matches_Text_With_Given_Input_Tags()
        {
            // arrange
            var demandedTags = new List<string> { "square", "circle", "cat" };
            var dbTag1 = TagModelFactory.Create(1, "rectangle");
            var dbTag2 = TagModelFactory.Create(2, "circle");
            var dbTag3 = TagModelFactory.Create(3, "flower");
            var dbTag4 = TagModelFactory.Create(4, "square");

            var dbTags = new List<Tag> { dbTag1, dbTag2, dbTag3, dbTag4 }.AsQueryable();

            // arrange-mock
            this.mockTbiContext.Setup(s => s.Tags.Provider).Returns(dbTags.Provider);
            this.mockTbiContext.Setup(s => s.Tags.Expression).Returns(dbTags.Expression);
            this.mockTbiContext.Setup(s => s.Tags.ElementType).Returns(dbTags.ElementType);
            this.mockTbiContext.Setup(s => s.Tags.GetEnumerator()).Returns(dbTags.GetEnumerator());

            // act
            var result = this.sut.GetTags(demandedTags);

            // assert
            Assert.NotNull(result);
            Assert.AreEqual(3, result.Count);
            Assert.True(result.Select(x => x.Id).Contains(4));
            Assert.True(result.Select(x => x.Id).Contains(2));
            Assert.True(result.Select(x => x.Id).Contains(0));

            Assert.True(result.Select(x => x.Text).Contains("square"));
            Assert.True(result.Select(x => x.Text).Contains("circle"));
            Assert.True(result.Select(x => x.Text).Contains("cat"));

            // assert-mock
            this.mockTbiContext.Verify(v => v.Tags, Times.Once);
        }
开发者ID:jstadnicki,项目名称:tbi,代码行数:34,代码来源:TagRepositoryTest.cs

示例9: DeberiActualizar

        public void DeberiActualizar()
        {
            var mockSet = new Mock<DbSet<Student>>();
            var mockContext = new Mock<UniversityContext>();
            mockContext.Setup(m => m.Students).Returns(mockSet.Object);
            var existing = new Student { StudentId = 1, Nombre = "Carlos", Paterno = "Estrada", Materno = "Copa", Telefono = 2269587 };
            var data = new Student
            {
                StudentId = 1,
                Nombre = "Carlos",
                Paterno = "Estrada",
                Materno = "Copa",
                Telefono = 2269587,
            };
            var queryable = new List<Student> { data }.AsQueryable();
            mockSet.As<IQueryable<Student>>().Setup(m => m.Provider).Returns(queryable.Provider);
            mockSet.As<IQueryable<Student>>().Setup(m => m.Expression).Returns(queryable.Expression);
            mockSet.As<IQueryable<Student>>().Setup(m => m.ElementType).Returns(queryable.ElementType);
            mockSet.As<IQueryable<Student>>().Setup(m => m.GetEnumerator()).Returns(queryable.GetEnumerator());
            mockContext.Setup(m => m.SaveChanges()).Verifiable();

            var service = new UniversityContextService(mockContext.Object);
            service.UpdateStudent(data);
            var mostrar = service.Show();

            mockContext.Verify();
            Assert.AreEqual(1, mostrar.Count);
            Assert.AreEqual("Carlos", mostrar[0].Nombre);
            Assert.AreEqual(2269587, mostrar[0].Telefono);
        }
开发者ID:diegoares02,项目名称:UniversityMOCK,代码行数:30,代码来源:TestMOQ.cs

示例10: GetPeopleOver21YearsOld

        public void GetPeopleOver21YearsOld()
        {
            var peopleOver21YearsOld = new List<Person>
            {
                new Person {Id = "1", Age = 25, Name = "Walter"},
                new Person {Id = "2", Age = 36, Name = "Euan"}
            };

            var expectedQuery = Query.GT("Age", 21);
            var databaseMock = new Mock<IMongoDatabase>();
            var peopleCollectionMock = new Mock<IMongoCollection<Person>>();
            var cursorMock = new Mock<IMongoCursor<Person>>();

            cursorMock.Setup(m => m.GetEnumerator()).Returns(peopleOver21YearsOld.GetEnumerator());

            databaseMock.Setup(m => m.GetCollection<Person>("People"))
                .Returns(peopleCollectionMock.Object);

            peopleCollectionMock.Setup(
                m => m.FindAs<Person>(It.Is<IMongoQuery>(query => query.ToString().Equals(expectedQuery.ToString()))))
                .Returns(cursorMock.Object);

            var applcationService = new ApplicationService(databaseMock.Object);

            Assert.AreEqual(2, applcationService.GetPeopleOver(21).Count());

            databaseMock.VerifyAll();
            peopleCollectionMock.VerifyAll();
            cursorMock.VerifyAll();
        }
开发者ID:myles-mcdonnell,项目名称:DCouple.Mongo,代码行数:30,代码来源:ApplicationServiceTests.cs

示例11: TestFilteredDocIdSet

        public virtual void TestFilteredDocIdSet()
        {
            const int maxdoc = 10;
            DocIdSet innerSet = new DocIdSetAnonymousInnerClassHelper(this, maxdoc);

            DocIdSet filteredSet = new FilteredDocIdSetAnonymousInnerClassHelper(this, innerSet);

            DocIdSetIterator iter = filteredSet.GetIterator();
            List<int?> list = new List<int?>();
            int doc = iter.Advance(3);
            if (doc != DocIdSetIterator.NO_MORE_DOCS)
            {
                list.Add(Convert.ToInt32(doc));
                while ((doc = iter.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    list.Add(Convert.ToInt32(doc));
                }
            }

            int[] docs = new int[list.Count];
            int c = 0;
            IEnumerator<int?> intIter = list.GetEnumerator();
            while (intIter.MoveNext())
            {
                docs[c++] = (int)intIter.Current;
            }
            int[] answer = new int[] { 4, 6, 8 };
            bool same = Arrays.Equals(answer, docs);
            if (!same)
            {
                Console.WriteLine("answer: " + Arrays.ToString(answer));
                Console.WriteLine("gotten: " + Arrays.ToString(docs));
                Assert.Fail();
            }
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:35,代码来源:TestDocIdSet.cs

示例12: Constructor_with_enumerator_argument_should_initialize_instance

 public void Constructor_with_enumerator_argument_should_initialize_instance()
 {
     var items = new List<int> { 1, 2 };
     var subject = new BatchableSource<int>(items.GetEnumerator());
     subject.Batch.Should().BeNull();
     subject.HasMore.Should().BeTrue();
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BatchableSourceTests.cs

示例13: testIndesReturnsAViewForTheRelevantProductID

        public void testIndesReturnsAViewForTheRelevantProductID()
        {
            var Products = new List<Product>
            {
                new Product{ID = 1,Title = "FirstProduct",Description = "First Product In Database"}
            }.AsQueryable();

            Mock<IHypermartContext> mockDBContext = new Mock<IHypermartContext>();

            var mockSet = new Mock<DbSet<Product>>();
            mockSet.As<IQueryable<Product>>().Setup(m => m.Provider).Returns(Products.Provider);
            mockSet.As<IQueryable<Product>>().Setup(m => m.Expression).Returns(Products.Expression);
            mockSet.As<IQueryable<Product>>().Setup(m => m.ElementType).Returns(Products.ElementType);
            mockSet.As<IQueryable<Product>>().Setup(m => m.GetEnumerator()).Returns(Products.GetEnumerator());

            mockDBContext.Setup(x => x.Products).Returns(mockSet.Object);

            var xy = mockDBContext.Object.Products.ToList();

            ProductsController SUT = new ProductsController(mockDBContext.Object);
            ActionResult  ViewResults =SUT.Index();
            ViewResult vResult = ViewResults as ViewResult;
            if (vResult != null)
            {
                Assert.AreEqual(string.Empty, vResult.ViewName);
                //Assert.IsInstanceOfType(typeof(Product),vResult.Model.GetType() );
                //Product model = vResult.Model as Product;
                //if (model != null)
                //{
                //    //...
                //}
            }
        }
开发者ID:computamike,项目名称:App-Utility-Store,代码行数:33,代码来源:ProductsControllerTests.cs

示例14: Can_Add_A_Product_Via_A_Controller

        public void Can_Add_A_Product_Via_A_Controller()
        {
            var mockEFContext = new Mock<IHypermartContext>();
            var Products = new List<Product>
            {
                new Product{ID = 1,Title = "FirstProduct",Description = "First Product In Database"}
            }.AsQueryable();

            var mockSet = new Mock<DbSet<Product>>();
            mockSet.As<IQueryable<Product>>().Setup(m => m.Provider).Returns(Products.Provider);
            mockSet.As<IQueryable<Product>>().Setup(m => m.Expression).Returns(Products.Expression);
            mockSet.As<IQueryable<Product>>().Setup(m => m.ElementType).Returns(Products.ElementType);
            mockSet.As<IQueryable<Product>>().Setup(m => m.GetEnumerator()).Returns(Products.GetEnumerator());

            mockEFContext.Setup(x => x.Products).Returns(mockSet.Object);

            var prodcontroller = new Open.GI.hypermart.Controllers.ProductsController() { db = mockEFContext.Object };

            var fakeHTTPSession = new TitaniumBunker.PhonySession.FonySession();
            fakeHTTPSession.AddFileUpload(new PhonyUploadFile("Screensjot.jpg", GetResourceAsStrream("TestAPI.img100.jpg"), "JPG"));
            prodcontroller.ControllerContext = fakeHTTPSession.BuildControllerContext(prodcontroller);
            prodcontroller.Url = new UrlHelper(fakeHTTPSession.BuildRequestContext());

            var res = prodcontroller.Create(new Product { ID = 2, Description = "foobar" });
        }
开发者ID:computamike,项目名称:App-Utility-Store,代码行数:25,代码来源:ControllerTestsUsingMOQ.cs

示例15: SetupChildren

 /// <summary>
 /// Setup the children of a folder.
 /// </summary>
 /// <param name="folder">Folder containing the children.</param>
 /// <param name="children">The children of the folder.</param>
 public static void SetupChildren(this Mock<IFolder> folder, params ICmisObject[] children) {
     var list = new Mock<IItemEnumerable<ICmisObject>>();
     var internalList = new List<ICmisObject>(children);
     list.Setup(l => l.TotalNumItems).Returns(children.LongLength);
     list.Setup(l => l.GetEnumerator()).Returns(internalList.GetEnumerator());
     folder.Setup(f => f.GetChildren()).Returns(list.Object);
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:12,代码来源:MockOfIFolderUtil.cs


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