本文整理汇总了C#中System.Linq.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# System.Linq.ToList方法的具体用法?C# System.Linq.ToList怎么用?C# System.Linq.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq
的用法示例。
在下文中一共展示了System.Linq.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Does_support_Sql_In_on_int_collections
public void Does_support_Sql_In_on_int_collections()
{
var ids = new[] { 1, 2, 3 };
Assert.That(expr().Where(q => Sql.In(q.Id, 1, 2, 3)).WhereExpression,
Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.Id, ids)).WhereExpression,
Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.Id, ids.ToList())).WhereExpression,
Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.Id, ids.ToList().Cast<object>())).WhereExpression,
Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));
}
示例2: RobotTest
public void RobotTest()
{
var commands = new[]
{
"Move 2",
"Turn right",
"Move 4",
"Turn left",
"Move -5",
"Turn right",
"Move 10",
"Turn left",
"Move -2",
"Turn left",
"Turn left",
"Move 5",
"Move -2",
"Turn right",
"Move 1",
"Move 0"
};
const int expectedX = 13;
const int expectedY = -8;
var grid = new Grid();
var robot = new Robot(grid);
commands.ToList().ForEach(robot.Command);
var actualX = robot.PositionX;
var actualY = robot.PositionY;
Assert.AreEqual(expectedX, actualX);
Assert.AreEqual(expectedY, actualY);
}
示例3: Does_support_Sql_In_on_string_collections
public void Does_support_Sql_In_on_string_collections()
{
var ids = new[] { "A", "B", "C" };
Assert.That(expr().Where(q => Sql.In(q.FirstName, "A", "B", "C")).WhereExpression,
Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.FirstName, ids)).WhereExpression,
Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.FirstName, ids.ToList())).WhereExpression,
Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));
Assert.That(expr().Where(q => Sql.In(q.FirstName, ids.ToList().Cast<object>())).WhereExpression,
Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));
}
示例4: EnableConversations
private void EnableConversations()
{
var itemstoEngage = new[]
{
By.CssSelector("#yucs-help_button"),
By.CssSelector("#yucs-help_button"), // has to be clicked twice to respond
By.XPath("//a[@data-mad='options']"),
By.CssSelector("li[data-name='viewing_email'] a"),
By.CssSelector("#options-enableConv"),
By.XPath("//div[contains(@class, 'modal-settings')]//button[contains(text(), 'Save')]")
};
Delay();
itemstoEngage.ToList().ForEach(it =>
{
Driver.RepeatFindAndExecuteAction
(
() => Driver.FindElements(it).FirstOrDefault(x => x.IsDisplayed()),
el =>
{
el.Click();
},
() => Delay(),
WebDriverDefaults.NumberOfRetriesForStaleExceptions
);
});
}
示例5: SendNotificationEmail
public void SendNotificationEmail()
{
var sender = CreateSender();
var reader = new ArticleReader();
var articles = new[] { reader.Read(new FileResources().Read("http://t/3530")) };
sender.Send(articles.ToList());
}
示例6: Absent_elements_should_be_included_in_result
public void Absent_elements_should_be_included_in_result()
{
var source = new[] { 6, 10, 5, 1 };
var sortedSource = _sort.Sort(source.ToList()).ToArray();
var filledSource = _filler.Fill(sortedSource);
Ass.Equal(new[] { 1, 2, 3, 4, 5, 6, 7 ,8, 9, 10 }, filledSource);
}
示例7: Absent_elements_should_be_displayed_in_result
public void Absent_elements_should_be_displayed_in_result()
{
var source = new[] { 6, 10, 5, 1, 12 };
var sortedSource = _sort.Sort(source.ToList()).ToArray();
var foundResults = _finder.Find(sortedSource);
Ass.Equal(new[] { "2-4", "7-9", "11" }, foundResults);
}
示例8: GetRangeTest
public void GetRangeTest([Values(0, 1)]int version, [Values(0, 1)]int count)
{
var aggregate = new EventAggregate();
var events = new[] { "a", "b", "c" };
using (var tran = aggregate.BeginTransaction())
{
aggregate.PushMany(-1, events);
tran.Commit();
}
CollectionAssert.AreEqual(events.ToList().GetRange(version, count), aggregate.GetRange(version, count));
}
示例9: ParseFileTest
public void ParseFileTest()
{
// arrange
var columns = new[] { "Column1", "Column2", "Column3" };
// act
var line = CsvUtil.ParseFile("TestData\\parsefile.csv", true).First();
// assert
columns.ToList().ForEach(
col =>
{
Assert.IsTrue(line.Any(l => l.Key == col));
});
}
示例10: LoadQuestions
private void LoadQuestions()
{
var questions = new[]
{
new Question
{
QuestionText = "Who didn't engineer the Apple Computer 1?",
Statements = new[] {"Bill Gates", "Steve Jobs", "Steve Wozniak", ""},
CorrectIndex = 2
}
};
var qd = new QuestionDatabase { Questions = questions.ToList() };
XML.Serialize(qd, "Data/questions.xml");
database = XML.Deserialize<QuestionDatabase>("Data/questions.xml");
}
示例11:
public void TestReactΔ()
{
var f = new MapFunction<int, int>(x => x + 1);
var numbers = new[] {10, 7, 12, 13, 6};
var value = f[numbers];
Assert.That(f.React(value, numbers.ToList().ToLog(Δ1.Empty)).Δ, Is.EqualTo(Δ1.Empty));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns()));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 13)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns()));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns()));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 7)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns()));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(1).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(1).ToDel()));
Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(3).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(3).ToDel()));
}
示例12: TestWithOneSetContainingUniverse
public void TestWithOneSetContainingUniverse()
{
var universe = new[] { 1, 2, 3, 4, 5 };
var sets = new[]
{
new[] { 1, 2, 3, 4, 5 },
new[] { 2, 3, 4, 5 },
new[] { 5 },
new[] { 3 }
};
var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());
var expectedResult = new[]
{
sets[0]
};
CollectionAssert.AreEqual(expectedResult, selectedSets);
}
示例13: TestWithAllSetsNeeded
public void TestWithAllSetsNeeded()
{
var universe = new[] { 1, 2, 3, 4, 5 };
var sets = new[]
{
new[] { 1, 3, 5 },
new[] { 1, 2 },
new[] { 3, 4 }
};
var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());
var expectedResult = new[]
{
sets[0],
sets[1],
sets[2]
};
CollectionAssert.AreEqual(expectedResult, selectedSets);
}
示例14: TestWithNoRedundantElements
public void TestWithNoRedundantElements()
{
var universe = new[] { 1, 2, 3, 4, 5 };
var sets = new[]
{
new[] { 1 },
new[] { 2, 4 },
new[] { 5 },
new[] { 3 }
};
var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());
var expectedResult = new[]
{
sets[1],
sets[0],
sets[2],
sets[3]
};
CollectionAssert.AreEqual(expectedResult, selectedSets);
}
示例15: TestWithSeveralRedundantSets
public void TestWithSeveralRedundantSets()
{
var universe = new[] { 1, 2, 3, 4, 5, 6 };
var sets = new[]
{
new[] { 1, 2, 5 },
new[] { 2, 3, 5 },
new[] { 3, 4, 5 },
new[] { 4, 5 },
new[] { 1, 3, 4, 6 }
};
var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());
var expectedResult = new[]
{
sets[4],
sets[0]
};
CollectionAssert.AreEqual(expectedResult, selectedSets);
}