本文整理汇总了C#中NUnit.Framework.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Adding_Multiple_Types_3
public void Adding_Multiple_Types_3()
{
var items = new List<string> { "Nav1", "Nav2", "Nav3" };
var a =
"div".Add(
"ul".Add(
items.Select(s => new NavRenderable { Text = s }),
"Start Nav 2",
items.Select(s => new NavRenderable { Text = s }),
"span".Add("Start Nav 3"),
items.Select(s => new NavRenderable { Text = s }),
"Nav over"))
.Add("div".Add("After div"));
Expect(a.ToString(), Is.EqualTo(
"<div>"
+ "<ul>"
+ "<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ "Start Nav 2"
+ "<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ "<span>Start Nav 3</span>"
+ "<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ "Nav over"
+ "</ul>"
+ "<div>After div</div>"
+ "</div>"));
}
示例2: CollectsAllBindingsAndLoadsThemDistinctOnKernel
public void CollectsAllBindingsAndLoadsThemDistinctOnKernel()
{
var loadedModules = new List<INinjectModule>();
A.CallTo(() => this.kernel.Load(A<IEnumerable<INinjectModule>>._))
.Invokes((IEnumerable<INinjectModule> modules) => loadedModules.AddRange(modules));
var dependencyA = new DependencyA();
var dependencyB = new DependencyB();
var dependencyDefinitionA = new Dependency<IDependencyA>(bind => bind.ToConstant(dependencyA).InTransientScope());
var dependencyDefinitionB = new Dependency<IDependencyB>(bind => bind.ToConstant(dependencyB).InSingletonScope());
this.testee.Load(
new FeatureA(
dependencyDefinitionA,
dependencyDefinitionB),
new FeatureB(
dependencyDefinitionA,
dependencyDefinitionB),
new FeatureC());
loadedModules.Select(_ => _.GetType().Name)
.Should().Contain(
new[]
{
typeof(ModuleA),
typeof(ModuleB),
typeof(ModuleC),
typeof(ModuleD)
}.Select(_ => _.Name))
.And.BeEquivalentTo(loadedModules.Select(_ => _.GetType().Name).Distinct());
}
示例3: D_visit_complete_tree_depthFirst_on_VisitDescendants
public void D_visit_complete_tree_depthFirst_on_VisitDescendants()
{
// ACT
var result = new List<Tuple<List<string>, string>>();
"rootNode".VisitDescendants(this.GetChildNodes, (b, n) => result.Add(Tuple.Create(b.ToList(), n)), depthFirst: true);
// ASSERT
Assert.AreEqual(5, result.Count());
CollectionAssert.AreEqual(new[] {
"leftNode",
"leftLeaf",
"rightNode",
"leftRightLeaf",
"rightRightLeaf"
}, result.Select(i => i.Item2));
CollectionAssert.AreEqual(new[] { "leftNode", "leftLeaf", "rightNode", "leftRightLeaf", "rightRightLeaf" }, result.Select(i => i.Item2));
CollectionAssert.AreEqual(new[] { "rootNode" }, result.ElementAt(0).Item1);
CollectionAssert.AreEqual(new[] { "rootNode", "leftNode" }, result.ElementAt(1).Item1);
CollectionAssert.AreEqual(new[] { "rootNode" }, result.ElementAt(2).Item1);
CollectionAssert.AreEqual(new[] { "rootNode", "rightNode" }, result.ElementAt(3).Item1);
CollectionAssert.AreEqual(new[] { "rootNode", "rightNode" }, result.ElementAt(4).Item1);
}
示例4: CanConvertConcurrently
public void CanConvertConcurrently()
{
var error = false;
var threads = new List<ThreadData>();
for (int i = 0; i < 5; i++)
{
var tmp = new ThreadData()
{
Thread = new Thread(ThreadStart),
WaitHandle = new ManualResetEvent(false)
};
threads.Add(tmp);
tmp.Thread.Start(tmp);
}
var handles = threads.Select(x => x.WaitHandle).ToArray();
Assert.IsTrue(WaitHandle.WaitAll(handles, ConcurrentTimeout), "At least one thread timeout");
//WaitAll(handles);
threads.ForEach(x => x.Thread.Abort());
var exceptions = threads.Select(x => x.Exception).Where(x => x != null);
foreach (var tmp in threads)
{
if (tmp.Exception != null)
{
error = true;
var tid = tmp.Thread.ManagedThreadId;
}
}
Assert.IsFalse(error, "At least one thread failed!");
}
示例5: CollectRepoFiles_collects_relative_filenames
public void CollectRepoFiles_collects_relative_filenames()
{
var repoFiles = new List<RepoFile>();
sut.CollectRepoFiles("TestData", repoFiles.Add);
var absoluteRepoRoot = Path.Combine(Directory.GetCurrentDirectory(), "TestData");
Assert.That(repoFiles.Select(x => x.RepoRoot).ToArray(), Is.EqualTo(
new[] {
absoluteRepoRoot,
absoluteRepoRoot,
absoluteRepoRoot,
absoluteRepoRoot,
absoluteRepoRoot,
absoluteRepoRoot
}));
Assert.That(repoFiles.Select(x => x.RelativeFileName).ToArray(), Is.EqualTo(new[] {
".sync",
"File1.txt",
"SubDir1\\File2.txt",
"SubDir1\\SubDir1a\\File3.txt",
"SubDir1\\SubDir1b\\File4.txt",
"SubDir2\\File5.txt"
}));
}
示例6: Korrekt_aufgebaute_Datei_wird_eingelesen
public void Korrekt_aufgebaute_Datei_wird_eingelesen() {
var jobs = new List<Job>();
sut.Jobs_einlesen(jobs.Add);
Assert.That(jobs.Select(x => x.Command).ToArray(), Is.EqualTo(new[] { "cmd1", "cmd2", "cmd3" }));
Assert.That(jobs.Select(x => x.Parameter1).ToArray(), Is.EqualTo(new[] { null, "p1", "p2" }));
Assert.That(jobs.Select(x => x.Parameter2).ToArray(), Is.EqualTo(new[] { null, null, "p3" }));
}
示例7: Can_receive_sequence_of_adds
public void Can_receive_sequence_of_adds()
{
var observable = CreateObservable();
var changes = new List<FirkinHashChange<string>>();
observable.Subscribe(changes.Add);
observable.Put("foo", 1.ToStream());
observable.Put("bar", 2.ToStream());
observable.Put("baz", 3.ToStream());
Assert.AreEqual(new[] { "foo", "bar", "baz" }, changes.Select(x => x.Key).ToArray());
Assert.AreEqual(new[] { FirkinHashChangeAction.Add, FirkinHashChangeAction.Add, FirkinHashChangeAction.Add }, changes.Select(x => x.Action).ToArray());
}
示例8: ParseEndUserSuppliedXriIdentifer
public void ParseEndUserSuppliedXriIdentifer() {
List<char> symbols = new List<char>(XriIdentifier.GlobalContextSymbols);
symbols.Add('(');
List<string> prefixes = new List<string>();
prefixes.AddRange(symbols.Select(s => s.ToString()));
prefixes.AddRange(symbols.Select(s => "xri://" + s.ToString()));
foreach (string prefix in prefixes) {
var id = Identifier.Parse(prefix + "andrew");
Assert.IsInstanceOfType(typeof(XriIdentifier), id);
}
}
示例9: ExtensionDisplayNameShouldBeUsedInBothStandardRoutes
public void ExtensionDisplayNameShouldBeUsedInBothStandardRoutes()
{
var blueprint = new ShellBlueprint {
Controllers = new[] {
new ControllerBlueprint {
AreaName ="Long.Name.Foo",
Feature =new Feature {
Descriptor=new FeatureDescriptor {
Extension=new ExtensionDescriptor {
Id="Foo",
Name="A Foo Module",
Path="Foo"
}
}
}
},
new ControllerBlueprint {
AreaName ="Long.Name.Bar",
Feature =new Feature {
Descriptor=new FeatureDescriptor {
Extension=new ExtensionDescriptor {
Id="Bar",
Name="Bar",
Path="BarBar"
}
}
}
}
}
};
var routeProvider = new StandardExtensionRouteProvider(blueprint);
var routes = new List<RouteDescriptor>();
routeProvider.GetRoutes(routes);
Assert.That(routes, Has.Count.EqualTo(4));
var fooAdmin = routes.Select(x => x.Route).OfType<Route>()
.Single(x => x.Url == "Admin/Foo/{action}/{id}");
var fooRoute = routes.Select(x => x.Route).OfType<Route>()
.Single(x => x.Url == "Foo/{controller}/{action}/{id}");
var barAdmin = routes.Select(x => x.Route).OfType<Route>()
.Single(x => x.Url == "Admin/BarBar/{action}/{id}");
var barRoute = routes.Select(x => x.Route).OfType<Route>()
.Single(x => x.Url == "BarBar/{controller}/{action}/{id}");
Assert.That(fooAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Foo"));
Assert.That(fooRoute.DataTokens["area"], Is.EqualTo("Long.Name.Foo"));
Assert.That(barAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Bar"));
Assert.That(barRoute.DataTokens["area"], Is.EqualTo("Long.Name.Bar"));
}
示例10: Adding_Multiple_NavRenderables
public void Adding_Multiple_NavRenderables()
{
var items = new List<string> { "Nav1", "Nav2", "Nav3" };
var a = "ul".Add(
items.Select(s => new NavRenderable { Text = s }),
items.Select(s => new NavRenderable { Text = s }),
items.Select(s => new NavRenderable { Text = s }));
Expect(a.ToString(), Is.EqualTo(
"<ul>"
+ @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>"
+ "</ul>"));
}
示例11: WhenSubscribedToAfterBindThenRaiseEventForEachMapping
public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping()
{
var listOfCalls = new List<BindMappingEventArgs>();
var configuration = new Configuration();
configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>());
configuration.AfterBindMapping += (sender, args) => { Assert.That(sender, Is.SameAs(configuration)); listOfCalls.Add(args); };
configuration.AddXmlString(ProductLineMapping);
configuration.AddXmlString(ModelMapping);
Assert.That(listOfCalls.Count, Is.EqualTo(2));
Assert.That(listOfCalls.Select(x => x.FileName).All(x => x != null), Is.True);
Assert.That(listOfCalls.Select(x => x.Mapping).All(x => x != null), Is.True);
Assert.That(listOfCalls.Select(x => x.Dialect).All(x => x.GetType() == typeof(MsSql2008Dialect)), Is.True);
}
示例12: WhenSubscribedToAfterBindThenRaiseEventForEachMapping
public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping()
{
var listOfCalls = new List<BindMappingEventArgs>();
var configuration = new Configuration();
configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>());
configuration.AfterBindMapping += (sender, args) => { sender.Should().Be.SameInstanceAs(configuration); listOfCalls.Add(args); };
configuration.AddXmlString(ProductLineMapping);
configuration.AddXmlString(ModelMapping);
listOfCalls.Count.Should().Be(2);
listOfCalls.Select(x => x.FileName).All(x => x.Satisfy(filename => filename != null));
listOfCalls.Select(x => x.Mapping).All(x => x.Satisfy(mappingDoc => mappingDoc != null));
listOfCalls.Select(x => x.Dialect).All(x => x.Satisfy(dialect => dialect.GetType() == typeof(MsSql2008Dialect)));
}
示例13: TestReadPersonWithMultiplePendingModificationsActivated
public void TestReadPersonWithMultiplePendingModificationsActivated()
{
// Make a separate copy from the main tree used in other tests
var tempTree = new FamilySearchFamilyTree(true);
var features = new List<Feature>();
tempTree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
// Get all the features that are pending
IRestRequest request = new RedirectableRestRequest()
.Accept(MediaTypes.APPLICATION_JSON_TYPE)
.Build("https://sandbox.familysearch.org/platform/pending-modifications", Method.GET);
IRestResponse response = tempTree.Client.Handle(request);
// Get each pending feature
features.AddRange(response.ToIRestResponse<FamilySearchPlatform>().Data.Features);
// Add every pending feature to the tree's current client
tempTree.Client.AddFilter(new ExperimentsFilter(features.Select(x => x.Name).ToArray()));
var state = tempTree.AddPerson(TestBacking.GetCreateMalePerson());
cleanup.Add(state);
// Ensure a response came back
Assert.IsNotNull(state);
var requestedFeatures = String.Join(",", state.Request.GetHeaders().Get("X-FS-Feature-Tag").Select(x => x.Value.ToString()));
// Ensure each requested feature was found in the request headers
Assert.IsTrue(features.TrueForAll(x => requestedFeatures.Contains(x.Name)));
}
示例14: MessageReceivedEvent
public void MessageReceivedEvent()
{
ICollection<RawMessage> expectedOutput = new List<RawMessage>();
expectedOutput.Add(new RawMessage("THEGAME", "a", "b", "cd ef g"));
string input = string.Join("\r\n", expectedOutput.Select((message) => message.ToString()).ToArray()) + "\r\n";
IEnumerator<RawMessage> messageChecker = expectedOutput.GetEnumerator();
var writer = new IO.Helpers.DummyRawMessageWriter();
using(var stringReader = new StringReader(input))
using(var reader = new RawMessageTextReader(stringReader)) {
using(var client = new Ondit.Client.Client(reader, writer)) {
client.RawMessageReceived += delegate(object sender, RawMessageEventArgs e) {
bool elementExists = messageChecker.MoveNext();
Assert.IsTrue(elementExists);
Assert.AreEqual(messageChecker.Current, e.Message);
};
foreach(var expectedMessage in expectedOutput) {
client.HandleMessage();
}
}
}
}
示例15: Succeed
public static void Succeed(params Action[] assertions)
{
var errors = new List<Exception>();
foreach (var assertion in assertions)
try
{
assertion();
}
catch (Exception ex)
{
errors.Add(ex);
}
if (errors.Any())
{
var ex = new AssertionException(
string.Join(Environment.NewLine, errors.Select(e => e.Message)),
errors.First());
// Use stack trace from the first exception to ensure first failed Assert is one click away
ReplaceStackTrace(ex, errors.First().StackTrace);
throw ex;
}
}