本文整理汇总了C#中NUnit.Framework.List.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# List.Reverse方法的具体用法?C# List.Reverse怎么用?C# List.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Reverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: valueComparator
internal static void valueComparator(RowSet rawrowset, List<object[]> insertedRows)
{
List<Row> rowset = rawrowset.GetRows().ToList();
Assert.True(rowset.Count == insertedRows.Count,
string.Format(
"Returned rows count is not equal with the count of rows that were inserted! \n Returned: {0} \n Expected: {1} \n",
rowset.Count, insertedRows.Count));
int i = 0;
foreach (Row row in rowset)
{
if (row.Any(col => col.GetType() == typeof (byte[])))
for (int j = 0; j < row.Length; j++)
{
Assert.AreEqual(insertedRows[i][j], row[j]);
}
else
{
for (int m = 0; m < row.Length; m++)
{
if (!row[m].Equals(insertedRows[i][m]))
{
insertedRows.Reverse(); // To check if needed and why
if (!row[m].Equals(insertedRows[i][m]))
insertedRows.Reverse();
}
Assert.AreEqual(insertedRows[i][m], row[m], "Inserted data does not match with returned data.");
}
}
i++;
}
}
示例2: BeforeClassSorterUtilTest
public void BeforeClassSorterUtilTest()
{
// only read the values of the undeleted documents, since after addIndexes,
// the deleted ones will be dropped from the index.
Bits liveDocs = reader.LiveDocs;
List<int> values = new List<int>();
for (int i = 0; i < reader.MaxDoc; i++)
{
if (liveDocs == null || liveDocs.Get(i))
{
values.Add(int.Parse(reader.Document(i).Get(ID_FIELD), CultureInfo.InvariantCulture));
}
}
int idx = Random().nextInt(SORT.Length);
Sort sorter = SORT[idx];
if (idx == 1)
{ // reverse doc sort
values.Reverse();
}
else
{
values.Sort();
if (Random().nextBoolean())
{
sorter = new Sort(new SortField(NUMERIC_DV_FIELD, SortField.Type_e.LONG, true)); // descending
values.Reverse();
}
}
sortedValues = values.ToArray();
if (VERBOSE)
{
Console.WriteLine("sortedValues: " + sortedValues);
Console.WriteLine("Sorter: " + sorter);
}
Directory target = NewDirectory();
using (IndexWriter writer = new IndexWriter(target, NewIndexWriterConfig(TEST_VERSION_CURRENT, null)))
{
using (reader = SortingAtomicReader.Wrap(reader, sorter))
{
writer.AddIndexes(reader);
}
}
dir.Dispose();
// CheckIndex the target directory
dir = target;
TestUtil.CheckIndex(dir);
// set reader for tests
reader = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(dir));
assertFalse("index should not have deletions", reader.HasDeletions);
}
示例3: TestGetPreviousTokenIncludingSkippedTokens
public void TestGetPreviousTokenIncludingSkippedTokens()
{
var text =
@"cbuffer Globals {
int a;
garbage
int b;
}";
var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text));
Assert.AreEqual(text, tree.Root.ToFullString());
var tokens = tree.Root.DescendantTokens(descendIntoTrivia: true).Where(t => t.Span.Length > 0).ToList();
Assert.AreEqual(11, tokens.Count);
Assert.AreEqual("garbage", tokens[6].Text);
var list = new List<SyntaxToken>(tokens.Count);
var token = tree.Root.GetLastToken(includeSkippedTokens: true);
while (token != null)
{
list.Add(token);
token = token.GetPreviousToken(includeSkippedTokens: true);
}
list.Reverse();
Assert.AreEqual(tokens.Count, list.Count);
for (int i = 0; i < tokens.Count; i++)
{
Assert.AreEqual(list[i], tokens[i]);
}
}
示例4: WontUpdateIfNoChangeInReferencesTest
public void WontUpdateIfNoChangeInReferencesTest()
{
var from = FileHelper.ResourceFileFor<VSProjectTest>("before.csproj.xml");
var projFile = FileHelper.CopyToTmpFile(from);
var proj = VSProject.FromPath(projFile);
var resources = new List<VSProject.Reference> {
new VSProject.Reference{Include="MyChildArtifactId1", HintPath="%CACHE_PATH%\\path\\to\\child1.ext"},
new VSProject.Reference{Include="MyChildArtifactId2",HintPath="%CACHE_PATH%\\path\\to\\child2.ext"}
};
var changed1stTime = proj.UpdateReferences(resources);
Assert.True(changed1stTime);
var orgWriteTime = projFile.LastWriteTime;
//wait a bit to let clock tick
Thread.Sleep(TimeSpan.FromSeconds(1));
//force an update, shou6ld check if already exist
resources.Reverse();
var changed2ndTime = proj.UpdateReferences(resources);
var newWriteTime = projFile.LastWriteTime;
Assert.False(changed2ndTime);
Assert.AreEqual(orgWriteTime, newWriteTime);
projFile.Delete();
}
示例5: GetSoretedList
private List<CodecMatch> GetSoretedList(params CodecMatch[] codecs)
{
var list = new List<CodecMatch>();
list.AddRange(codecs);
list.Sort();
list.Reverse();//we want from higher to smaller
return list;
}
示例6: ReversedList
public void ReversedList()
{
// Note: mustn't give source a compile-time type of List<int> as
// List<T> has a Reverse method.
IEnumerable<int> source = new List<int> { 5, 6, 7, 8, 9 };
var query = source.Reverse();
query.AssertSequenceEqual(9, 8, 7, 6, 5);
}
示例7: ReverseQueryReuse
public void ReverseQueryReuse()
{
List<int> data = new List<int> { 1, 2, 3 };
IEnumerable<int> enumerable = data.Reverse<int>(); // # Using Reverse<int> (with type parameter) in order to avoid calling List<int>.Reverse()
enumerable.AssertEqual(3, 2, 1);
data.Add(4);
enumerable.AssertEqual(4, 3, 2, 1);
}
示例8: Reverse_Iterator_Is_Inverse_of_Forward_Iterator
public void Reverse_Iterator_Is_Inverse_of_Forward_Iterator()
{
List<DataTable> forwardItems = new List<DataTable>();
foreach (DataTable dt in _forwardIterator)
{
forwardItems.Add(dt);
}
forwardItems.Reverse();
Assert.That(forwardItems, Is.EquivalentTo(_reverseIterator));
}
示例9: Arrange
public void Arrange()
{
//_originalValues = new List<String>{"BankVue", "Should", "Hire", "Elliott"};
// lets check some performance issues
_originalValues = new List<string>();
for (var i = 0; i < 1000000; i++ )
{
_originalValues.Add(Guid.NewGuid().ToString());
}
_list = new CheatingLinkedList<String>();
_expectedValues = new List<String>(_originalValues);
_expectedValues.Reverse();
}
示例10: Get1sInNumber
public IEnumerable<int> Get1sInNumber(int length, int perm)
{
int digit = 0;
List<int> result = new List<int>();
while (perm > 0)
{
if ((perm & 1) == 1)
result.Add(digit);
digit++;
perm /= 2;
}
result.Reverse();
return result.Select(o => length - o - 1);
}
示例11: DifferShouldDiffArraysByObjectEqualityByDefault
public void DifferShouldDiffArraysByObjectEqualityByDefault()
{
IEnumerable<TestObj> array = new List<TestObj>
{
new TestObj
{
Id = 1
},
new TestObj
{
Id = 2
}
};
var diff = _differ.Diff(array, array.Reverse());
Assert.IsNull(diff);
}
示例12: Prepend_ToList
public void Prepend_ToList()
{
Tuple<Table<EntityWithListType>, List<EntityWithListType>> tupleListType = EntityWithListType.SetupDefaultTable(_session);
Table<EntityWithListType> table = tupleListType.Item1;
List<EntityWithListType> expectedEntities = tupleListType.Item2;
List<int> listToAdd = new List<int> { -1, 0, 5, 6 };
List<int> listReversed = new List<int>(listToAdd);
listReversed.Reverse();
EntityWithListType singleEntity = expectedEntities.First();
EntityWithListType expectedEntity = singleEntity.Clone();
expectedEntity.ListType.InsertRange(0, listReversed);
// Append the values
table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.Prepend(listToAdd) }).Update().Execute();
// Validate final state of the data
var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
Assert.AreEqual(1, entityList.Count);
Assert.AreNotEqual(expectedEntity.ListType, singleEntity.ListType);
expectedEntity.AssertEquals(entityList[0]);
}
示例13: EncodingTypeCompare
public void EncodingTypeCompare()
{
List<EncodingType> list = new List<EncodingType>(
new EncodingType[]
{
EncodingType.Parse("identity;q=0.5"),
EncodingType.Parse("*;q=0"),
EncodingType.Parse("gzip;q=1.0")
});
list.Sort();
list.Reverse();
Assert.AreEqual("gzip", list[0].ToString());
Assert.AreEqual("identity;q=0.5", list[1].ToString());
Assert.AreEqual("*;q=0", list[2].ToString());
Assert.IsTrue(EncodingType.Empty > (EncodingType)null);
Assert.IsTrue(EncodingType.Parse("gzip") > EncodingType.Parse("gzip;q=0.5"));
Assert.IsTrue((EncodingType)null < EncodingType.Empty);
Assert.IsTrue(EncodingType.Parse("gzip;q=0.5") < EncodingType.Parse("gzip"));
}
示例14: DifferShouldDiffObjectArrayElementsByIndexWhenUsingIndexEnumerableDiffer
public void DifferShouldDiffObjectArrayElementsByIndexWhenUsingIndexEnumerableDiffer()
{
var differ = GetDiffer(true);
var obj1 = new TestObj
{
Id = 1
};
var obj2 = new TestObj
{
Id = 2
};
IEnumerable<TestObj> array = new List<TestObj>
{
obj1, obj2
};
// should return 2 child diffs, one for each array element, even though the elements in each array are equal
var diff = differ.Diff(array, array.Reverse());
Assert.AreEqual(2, diff.ChildDiffs.Count());
Assert.IsTrue(diff.ChildDiffs.Any(d => d.NewValue == obj1 && d.OldValue == obj2));
Assert.IsTrue(diff.ChildDiffs.Any(d => d.NewValue == obj2 && d.OldValue == obj1));
}
示例15: query_paged_post_test
public void query_paged_post_test()
{
var authorId = ObjectId.GenerateNewStringId();
var subject = ObjectId.GenerateNewStringId();
var body = ObjectId.GenerateNewStringId();
var sectionId = ObjectId.GenerateNewStringId();
var postIds = new List<string>();
var totalPostCount = 10;
var replyCountPerPost = 2;
var pageSize = 2;
for (var i = 0; i < totalPostCount; i++)
{
var postId = ExecuteCommand(new CreatePostCommand(subject, body, sectionId, authorId)).AggregateRootId;
for (var j = 0; j < replyCountPerPost; j++)
{
ExecuteCommand(new CreateReplyCommand(postId, null, body, authorId));
}
postIds.Add(postId);
}
postIds.Reverse();
var queryService = ObjectContainer.Resolve<IPostQueryService>();
for (var pageIndex = 1; pageIndex <= totalPostCount / pageSize; pageIndex++)
{
var posts = queryService.Find(new PostQueryOption { SectionId = sectionId, PageInfo = new PageInfo { PageIndex = pageIndex, PageSize = pageSize } }).Posts.ToList();
Assert.AreEqual(replyCountPerPost, posts.Count());
var expectedPostIds = postIds.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
for (var i = 0; i < pageSize; i++)
{
Assert.AreEqual(expectedPostIds[i], posts[i].Id);
Assert.AreEqual(replyCountPerPost, posts[i].ReplyCount);
}
}
}