當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。