本文整理汇总了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());
}
示例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");
}
示例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());
}
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}