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


C# List.AsEnumerable方法代码示例

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


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

示例1: GetPersonsReturnsAllFromRepository

        public void GetPersonsReturnsAllFromRepository()
        {
            List<Person> persons = new List<Person>();
            persons.Add(new Person("a", 1, "a"));
            persons.Add(new Person("b", 2, "b"));

            var repositoryMock = new Mock<PersonRepository>();
            repositoryMock.Setup<IEnumerable<Person>>(x => x.GetAll()).Returns(persons.AsEnumerable());

            var facade = new PersonFacade(repositoryMock.Object, null);

            Assert.AreEqual(persons.AsEnumerable(), facade.GetPersons());
        }
开发者ID:gergelykoncz,项目名称:Patterns.Specification,代码行数:13,代码来源:PersonFacadeTests.cs

示例2: Enumerable_FirstOne_Should_Return_First_Item

        public void Enumerable_FirstOne_Should_Return_First_Item()
        {
            var list = new List<string> { "First", "Second", "Third" };
            var first = list.AsEnumerable().FirstOne();

            Assert.AreEqual(first, "First");
        }
开发者ID:remyblok,项目名称:BetterModules,代码行数:7,代码来源:QueryableExtensionsTests.cs

示例3: AutoFilterExpandsWithTable

        public void AutoFilterExpandsWithTable()
        {
            using (var wb = new XLWorkbook())
            {
                using (IXLWorksheet ws = wb.Worksheets.Add("Sheet1"))
                {
                    ws.FirstCell().SetValue("Categories")
                        .CellBelow().SetValue("1")
                        .CellBelow().SetValue("2");

                    IXLTable table = ws.RangeUsed().CreateTable();

                    var listOfArr = new List<Int32>();
                    listOfArr.Add(3);
                    listOfArr.Add(4);
                    listOfArr.Add(5);
                    listOfArr.Add(6);

                    table.DataRange.InsertRowsBelow(listOfArr.Count - table.DataRange.RowCount());
                    table.DataRange.FirstCell().InsertData(listOfArr.AsEnumerable());

                    Assert.AreEqual("A1:A5", table.AutoFilter.Range.RangeAddress.ToStringRelative());
                }
            }
        }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:25,代码来源:AutoFilterTests.cs

示例4: PagedList_BuildPagingLastPage_Valid

        public void PagedList_BuildPagingLastPage_Valid()
        {
            const int page = 3;
            const int pageSize = 1;
            const int shownEitherSide = 1;
            const string url = "url";

            List<string> source = new List<string> { "one", "two", "three" };

            var pagedList = new PagedList<string>(source.AsEnumerable(), page, pageSize);

            var actual = pagedList.BuildPagingLinks(shownEitherSide, url);

            const string expected = "<div class=\"pagination\">" +
                                        "<span class=\"page\"></span>" +
                                        "<ul>" +
                                            "<li><a href=\"url?page=1\">First</a></li>" +
                                            "<li><a href=\"url?page=2\">Prev</a></li>" +
                                            "<li><a href=\"url?page=1\">... </a></li>" +
                                            "<li><a href=\"url?page=2\">2</a></li>" +
                                            "<li class=\"current\"><a href=\"url?page=3\">3</a></li>" +
                                            "<li><a href=\"url?page=3\">Next</a></li>" +
                                            "<li><a href=\"url?page=3\">Last</a></li>" +
                                        "</ul>" +
                                    "</div>";

            Assert.AreEqual(expected, actual);
        }
开发者ID:leegould,项目名称:PagedList,代码行数:28,代码来源:PagedListTest.cs

示例5: TestCSharpInputDStream

        public void TestCSharpInputDStream()
        {
            // test create CSharpInputDStream
            var sc = new SparkContext("", "");
            var ssc = new StreamingContext(sc, 1000L);
            Func<double, int, IEnumerable<string>> func =
                (double time, int pid) =>
                {
                    var list = new List<string>() { string.Format("PluggableInputDStream-{0}-{1}", pid, time) };
                    return list.AsEnumerable();
                };
            const int numPartitions = 5;
            var inputDStream = CSharpInputDStreamUtils.CreateStream<string>(
                ssc,
                numPartitions,
                func);
            Assert.IsNotNull(inputDStream);
            Assert.AreEqual(ssc, inputDStream.streamingContext);

            // test CSharpInputDStreamMapPartitionWithIndexHelper
            int[] array = new int[numPartitions];
            int partitionIndex = 0;
            new CSharpInputDStreamMapPartitionWithIndexHelper<string>(0.0, func).Execute(partitionIndex, array.AsEnumerable());

            // test CSharpInputDStreamGenerateRDDHelper
            new CSharpInputDStreamGenerateRDDHelper<string>(numPartitions, func).Execute(0.0);
        }
开发者ID:jthelin,项目名称:SparkCLR,代码行数:27,代码来源:DStreamTest.cs

示例6: GetApplicationSpecificClaims

        protected virtual IEnumerable<Claim> GetApplicationSpecificClaims()
        {
            var result = new List<Claim>();

            if( IncludeTargetedUserLEAIds())
                result.Add(new Claim(EdFiClaimTypes._OrgClaimNamespace, string.Format(localEducationAgencyIdClaimJsonFormatString, administerLeaId, administerLeaName)));

            return result.AsEnumerable();
        }
开发者ID:sybrix,项目名称:EdFi-App,代码行数:9,代码来源:GetImpersonatedClaimsDataProviderFixture.cs

示例7: ConstructorGivenAnEnumerableCopiesIt

        public void ConstructorGivenAnEnumerableCopiesIt()
        {
            var list = new List<int> { 1, 2, 3 };
            var observableList = new ObservableList<int>(list.AsEnumerable()) { 4 };
            list.Remove(1);

            Assert.AreEqual(4, observableList.Count);
            Assert.AreEqual(2, list.Count);
        }
开发者ID:renangrativol,项目名称:DamienGKit,代码行数:9,代码来源:ObservableListTests.cs

示例8: ForEach_WithCollectionOfOneItem_ShouldIterateOneTime

        public void ForEach_WithCollectionOfOneItem_ShouldIterateOneTime()
        {
            var collection = new List<int> { 1 };
            var iterations = 0;

            collection.AsEnumerable().ForEach(num => iterations++);

            Assert.That(iterations, Is.EqualTo(1));
        }
开发者ID:jackingod,项目名称:jessica,代码行数:9,代码来源:EnumerableExtensionsTests.cs

示例9: Double_NaN_is_a_string

        public void Double_NaN_is_a_string()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLCell cell = ws.Cell("A1");
            var doubleList = new List<Double> {0.0/0.0};

            cell.Value = doubleList.AsEnumerable();
            Assert.AreNotEqual(XLCellValues.Number, cell.DataType);
        }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:9,代码来源:XLCellTests.cs

示例10: ForEach_WithEmptyCollection_ShouldIterateZeroTimes

        public void ForEach_WithEmptyCollection_ShouldIterateZeroTimes()
        {
            var collection = new List<int>();
            var iterations = 0;

            collection.AsEnumerable().ForEach(num => iterations++);

            Assert.That(iterations, Is.EqualTo(0));
        }
开发者ID:jackingod,项目名称:jessica,代码行数:9,代码来源:EnumerableExtensionsTests.cs

示例11: ForEach_WithCollectionOfTenItems_ShouldIterateTenTimes

        public void ForEach_WithCollectionOfTenItems_ShouldIterateTenTimes()
        {
            var collection = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var iterations = 0;

            collection.AsEnumerable().ForEach(num => iterations++);

            Assert.That(iterations, Is.EqualTo(10));
        }
开发者ID:jackingod,项目名称:jessica,代码行数:9,代码来源:EnumerableExtensionsTests.cs

示例12: GetAllComponentReturnsAllItems_Test

        public async Task GetAllComponentReturnsAllItems_Test()
        {
            var createdComponents = new List<Component> {CreateComponent(), CreateComponent(), CreateComponent()};

            _storageMock.Setup(x => x.GetItems()).Returns(() => Task.FromResult(createdComponents.AsEnumerable()));

            var components = await _model.GetAllComponentsAsync();
            _storageMock.Verify(x => x.GetItems(), Times.Exactly(1));
            Assert.AreEqual(createdComponents, components);
        }
开发者ID:acid84,项目名称:FoodMaster,代码行数:10,代码来源:ComponentsModelTests.cs

示例13: ReportListGenerator

 public IEnumerable<Report> ReportListGenerator()
 {
     int iCount = 5;
     var x = new List<Report>();
     while (iCount > 0)
     {
         x.Insert(0, new Report() { ID = iCount, Name = "Report #" + iCount });
         iCount--;
     }
     return x.AsEnumerable();
 }
开发者ID:SirPhobos,项目名称:RMM,代码行数:11,代码来源:ReportHubServiceTests.cs

示例14: GetImpersonatorClaims

        protected virtual IEnumerable<Claim> GetImpersonatorClaims()
        {
            var result = new List<Claim>();

            if( IncludeAdministerStateId())
                result.Add(new Claim(EdFiClaimTypes.AdministerDashboard, string.Format(stateAgencyClaimJsonFormatString, administerStateId, administerStateName)));

            if (IncludeAdministerLeaID())
                result.Add(new Claim(EdFiClaimTypes.AdministerDashboard, string.Format(localEducationAgencyIdClaimJsonFormatString, administerLeaId, administerLeaName)));

            return result.AsEnumerable();
        }
开发者ID:sybrix,项目名称:EdFi-App,代码行数:12,代码来源:GetImpersonatedClaimsDataProviderFixture.cs

示例15: CreatePackageItemListViewModel

		PackageItemListViewModel CreatePackageItemListViewModel ()
		{
			packageVersions = new List<VersionInfo> ();
			packageItemListViewModel = new PackageItemListViewModel {
				Id = "TestPackage",
				Version = new NuGetVersion ("1.2.3"),
				Versions = AsyncLazy.New (() => {
					return Task.FromResult (packageVersions.AsEnumerable ());
				})
			};
			return packageItemListViewModel;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:12,代码来源:PackageSearchResultViewModelTests.cs


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