本文整理汇总了C#中NUnit.Framework.List.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# List.Skip方法的具体用法?C# List.Skip怎么用?C# List.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send_Given30TosAnd30Bccs_SendTwoBatches
public void Send_Given30TosAnd30Bccs_SendTwoBatches()
{
var senderMock = new Mock<IEmailSender>();
var service = new Portal.EmailService.EmailService(senderMock.Object);
var tos = new List<string>();
var bccs = new List<string>();
const string from = "[email protected]";
const string subject = "Test Email";
const string body = "<div>Hallo test</div>";
for (var i = 0; i < 30; i++)
tos.Add(string.Format("MyMail{0}@test.test", i));
for (var i = 0; i < 30; i++)
bccs.Add(string.Format("MyBccMail{0}@test.test", i));
IList<SendEmailRequest> request = new List<SendEmailRequest>();
senderMock.SetupGet(s => s.MaxRecipientPerBatch).Returns(50);
senderMock.Setup(s => s.Send(It.IsAny<SendEmailRequest>())).Callback<SendEmailRequest>(request.Add);
service.Send(from, tos, bccs, subject, body);
senderMock.Verify(s => s.Send(It.IsAny<SendEmailRequest>()), Times.Exactly(2));
Assert.That(request.Count, Is.EqualTo(2));
Assert.That(request.First().Destination.ToAddresses.Count, Is.EqualTo(30));
Assert.That(request.First().Destination.BccAddresses.Count, Is.EqualTo(20));
Assert.That(request.Skip(1).First().Destination.ToAddresses.Count, Is.EqualTo(0));
Assert.That(request.Skip(1).First().Destination.BccAddresses.Count, Is.EqualTo(10));
}
示例2: ShouldHaveImportantViaAddress
public void ShouldHaveImportantViaAddress()
{
int symbolNumber = 0;
var symbols = new List<Symbol>();
//reverse order according to type importance. This is not optimal, but the actual
//importance is private to Symbol type.
foreach(var type in new []{ SymbolType.Function,
SymbolType.NotSpecified,
SymbolType.ProcessorSpecific,
SymbolType.Section,
SymbolType.Object,
SymbolType.File })
{
foreach(var binding in new []{ SymbolBinding.Global,
SymbolBinding.Local,
SymbolBinding.ProcessorSpecific,
SymbolBinding.Weak })
{
symbols.Add(new Symbol(0, 10, symbolNumber.ToString(), type, binding));
symbolNumber++;
}
}
//check every symbol. The symbol in question and all LESS important are added, both in order and in reverse order.
for(var i = 0; i < symbols.Count; ++i)
{
var lookup = new SymbolLookup();
lookup.InsertSymbols(symbols.Skip(i));
Assert.AreEqual(symbols[i], lookup.GetSymbolByAddress(5));
lookup = new SymbolLookup();
lookup.InsertSymbols(symbols.Skip(i).Reverse());
Assert.AreEqual(symbols[i], lookup.GetSymbolByAddress(5));
}
}
示例3: Tokens3CorrectDoNothing_Test
public void Tokens3CorrectDoNothing_Test()
{
string String = "{0} {1} {2}";
List<int> List = new List<int> { 0, 1, 2 };
FixStringAndList(ref String, ref List);
Assert.AreEqual("{0} {1} {2}", String);
Assert.AreEqual(0, List.First());
Assert.AreEqual(1, List.Skip(1).First());
Assert.AreEqual(2, List.Skip(2).First());
}
示例4: Tokens3singleDup_Test
public void Tokens3singleDup_Test()
{
string String = "{2} {1} {0}";
List<int> List = new List<int> { 2, 1, 0 };
FixStringAndList(ref String, ref List);
Assert.AreEqual("{0} {1} {2}", String);
Assert.AreEqual(0, List.First());
Assert.AreEqual(1, List.Skip(1).First());
Assert.AreEqual(2, List.Skip(2).First());
}
示例5: RaisesSendingEventForEachRequest
public void RaisesSendingEventForEachRequest()
{
_server.OnGet("/foo").RespondWith("awww yeah");
var client = new RestClient(BaseAddress);
var sendingEvents = new List<RequestDetails>();
client.Sending += (sender, args) => sendingEvents.Add(args.Request);
client.Get(BaseAddress + "/foo?omg=yeah");
Assert.That(sendingEvents.Single().RequestUri.PathAndQuery, Is.EqualTo("/foo?omg=yeah"));
Assert.That(sendingEvents.Single().Method, Is.EqualTo("GET"));
client.Get(BaseAddress + "/foo?omg=nah");
Assert.That(sendingEvents.Skip(1).Single().RequestUri.PathAndQuery, Is.EqualTo("/foo?omg=nah"));
Assert.That(sendingEvents.Skip(1).Single().Method, Is.EqualTo("GET"));
}
示例6: Should_Add_Two_Items_To_Existing_List
public void Should_Add_Two_Items_To_Existing_List() {
// Arrange
IList<int> list = new List<int>(new[] { 1, 2 });
// Act
list.AddRange(new[] { 3, 4 });
// Assert
list.ShouldNotBeEmpty();
list.Count.ShouldEqual(4);
list.First().ShouldEqual(1);
list.Skip(1).First().ShouldEqual(2);
list.Skip(2).First().ShouldEqual(3);
list.Last().ShouldEqual(4);
}
示例7: Add
public void Add()
{
var mruCollection = new MostRecentlyUsedCollection();
var paths = new List<string>();
for (int i = 0; i <= mruCollection.MaximumSize; i++)
{
paths.Add(
string.Format(
CultureInfo.InvariantCulture,
@"c:\temp\myfile{0}.txt",
i));
}
for (int i = 0; i < paths.Count; i++)
{
mruCollection.Add(paths[i]);
Assert.That(
mruCollection.Select(m => m.FilePath),
Is.EquivalentTo(
paths
.Skip(i >= mruCollection.MaximumSize ? i - mruCollection.MaximumSize + 1 : 0)
.Take(i >= mruCollection.MaximumSize ? mruCollection.MaximumSize : i + 1)
.Reverse()));
}
}
示例8: 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 = _commandService.Execute(new CreatePostCommand(subject, body, sectionId, authorId), CommandReturnType.EventHandled).WaitResult<CommandResult>(10000).AggregateRootId;
for (var j = 0; j < replyCountPerPost; j++)
{
_commandService.Execute(new CreateReplyCommand(postId, null, body, authorId)).Wait();
}
postIds.Add(postId);
}
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);
}
}
}
示例9: be_able_to_read_all_one_by_one_and_return_empty_slice_at_last
public void be_able_to_read_all_one_by_one_and_return_empty_slice_at_last()
{
const string stream = "read_all_events_forward_should_be_able_to_read_all_one_by_one_and_return_empty_slice_at_last";
using (var store = EventStoreConnection.Create())
{
store.Connect(Node.TcpEndPoint);
var create = store.CreateStreamAsync(stream, false, new byte[0]);
Assert.DoesNotThrow(create.Wait);
var testEvents = Enumerable.Range(0, 5).Select(x => new TestEvent((x + 1).ToString())).ToArray();
var write = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, testEvents);
Assert.DoesNotThrow(write.Wait);
var all = new List<RecordedEvent>();
var position = Position.Start;
AllEventsSlice slice;
while ((slice = store.ReadAllEventsForward(position, 1)).Events.Any())
{
all.Add(slice.Events.Single());
position = slice.Position;
}
Assert.That(TestEventsComparer.Equal(testEvents, all.Skip(1).ToArray()));
}
}
示例10: GetFrom_StartId
public void GetFrom_StartId()
{
savedIds = savedIds.OrderByDescending(i => i).ToList();
var firstTwo = repos.GetNewFrom(2).Select(p => p.Id);
Assert.That(firstTwo, Is.EquivalentTo(savedIds.Take(2)));
var nextTwo = repos.GetNewFrom(2, firstTwo.Min()).Select(p => p.Id);
Assert.That(nextTwo, Is.EquivalentTo(savedIds.Skip(2).Take(2)));
}
示例11: Tokens2SimpleInvert_Test
public void Tokens2SimpleInvert_Test()
{
string String = "{1} {0}";
List<int> List = new List<int> { 1, 0 };
FixStringAndList(ref String, ref List);
Assert.AreEqual("{0} {1}", String);
Assert.AreEqual(0, List.First());
Assert.AreEqual(1, List.Skip(1).First());
}
示例12: Should_Apply_All_Migrations_Up_To_Given_Version
public void Should_Apply_All_Migrations_Up_To_Given_Version()
{
var sourceMigrations = new List<IMigration>()
{
Mock.Of<IMigration>(m => m.Version == "0.0"),
Mock.Of<IMigration>(m => m.Version == "0.0.1"),
Mock.Of<IMigration>(m => m.Version == "0.1"),
};
var migrationsService = new MigrationsService();
foreach (var migration in sourceMigrations)
migrationsService.Register(migration);
migrationsService.Migrate("", "0.1");
int index = 0;
Mock.Get(sourceMigrations.Skip(index++).First()).Verify(mockmigration => mockmigration.Apply());
Mock.Get(sourceMigrations.Skip(index++).First()).Verify(mockmigration => mockmigration.Apply());
Mock.Get(sourceMigrations.Skip(index++).First()).Verify(mockmigration => mockmigration.Apply(), Times.Never);
}
示例13: be_able_to_read_events_slice_at_time
public void be_able_to_read_events_slice_at_time()
{
var all = new List<RecordedEvent>();
var position = Position.Start;
AllEventsSlice slice;
while (!(slice = _conn.ReadAllEventsForwardAsync(position, 5, false).Result).IsEndOfStream)
{
all.AddRange(slice.Events.Select(x => x.Event));
position = slice.NextPosition;
}
Assert.That(EventDataComparer.Equal(_testEvents, all.Skip(all.Count - _testEvents.Length).ToArray()));
}
示例14: be_able_to_read_all_one_by_one_until_end_of_stream
public void be_able_to_read_all_one_by_one_until_end_of_stream()
{
var all = new List<RecordedEvent>();
var position = Position.Start;
AllEventsSlice slice;
while (!(slice = _conn.ReadAllEventsForwardAsync(position, 1, false).Result).IsEndOfStream)
{
all.Add(slice.Events.Single().Event);
position = slice.NextPosition;
}
Assert.That(EventDataComparer.Equal(_testEvents, all.Skip(all.Count - _testEvents.Length).ToArray()));
}
示例15: SetUp
public void SetUp()
{
words = Values.AtoZ().SelectMany(c => Enumerable.Range(1, 100).Select(i => c + i)).ToList();
partitions = Values.AtoZ().Select(c => Partition.Where<string>(s => s.StartsWith(c), named: c));
partitionedStream = Stream
.Partitioned<string, int, string>(
query: async (q, partition) =>
{
var wordsInPartition = words
.Skip(q.Cursor.Position)
.Where(partition.Contains);
var b = wordsInPartition
.Take(q.BatchSize.Value);
return b;
},
advanceCursor: (query, batch) => { query.Cursor.AdvanceTo(words.IndexOf(batch.Last()) + 1); });
Formatter.ListExpansionLimit = 100;
Formatter<Projection<HashSet<int>, int>>.RegisterForAllMembers();
}