本文整理汇总了C#中NUnit.Framework.List.Single方法的典型用法代码示例。如果您正苦于以下问题:C# List.Single方法的具体用法?C# List.Single怎么用?C# List.Single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Single方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckContacts
private static void CheckContacts(XmlNode ctrNode, List<Contact> contacts)
{
var jnode = ctrNode.GetXmlAttribute("J");
var knode = ctrNode.GetXmlAttribute("K");
var lnode = ctrNode.GetXmlAttribute("L");
var mnode = ctrNode.GetXmlAttribute("M");
if (!string.IsNullOrEmpty(jnode))
{
var fixedPhoneContact = contacts.Single(x => x.Type == ContactTypeEnum.FixedPhone);
Assert.AreEqual(jnode, fixedPhoneContact.Number);
}
if (!string.IsNullOrEmpty(knode))
{
var mobilePhoneContact = contacts.Single(x => x.Type == ContactTypeEnum.MobilePhone);
Assert.AreEqual(knode, mobilePhoneContact.Number);
}
if (!string.IsNullOrEmpty(lnode))
{
var faxContact = contacts.Single(x => x.Type == ContactTypeEnum.Fax);
Assert.AreEqual(lnode, faxContact.Number);
}
if (!string.IsNullOrEmpty(mnode))
{
var emailContact = contacts.Single(x => x.Type == ContactTypeEnum.Email);
Assert.AreEqual(mnode, emailContact.Number);
}
}
示例2: TestFooList
public void TestFooList()
{
var orig = new List<Foo> { new Foo() { Count = 12, Name = "abc" } };
var clone = Serializer.DeepClone(orig).Single();
Assert.AreEqual(orig.Single().Count, clone.Count);
Assert.AreEqual(orig.Single().Name, clone.Name);
}
示例3: StillRaisesSendingEventWhenSendingThrows
public void StillRaisesSendingEventWhenSendingThrows()
{
var sendingEvents = new List<RequestDetails>();
var client = new RestClient(new Uri(BaseAddress), new AlwaysThrowsOnSendingAdapter(), new List<PipelineOption>());
client.Sending += (sender, args) => sendingEvents.Add(args.Request);
Assert.That(() => client.Get("/foo?omg=yeah"), Throws.InstanceOf<DeliberateException>());
Assert.That(sendingEvents.Single().RequestUri.PathAndQuery, Is.EqualTo("/foo?omg=yeah"));
Assert.That(sendingEvents.Single().Method, Is.EqualTo("GET"));
}
示例4: RaisesRespondedEventForEachRequest
public void RaisesRespondedEventForEachRequest()
{
_server.OnGet("/foo").Respond((req, res) => res.StatusCode = 418);
var client = new RestClient(BaseAddress);
var respondedEvents = new List<ResponseEventArgs>();
client.Responded += (sender, args) => respondedEvents.Add(args);
client.Get("/foo?teapot=yes", new ExpectStatus((HttpStatusCode)418));
Assert.That(respondedEvents.Single().Response.Status, Is.EqualTo(418));
Assert.That(respondedEvents.Single().Request.RequestUri.PathAndQuery, Is.EqualTo("/foo?teapot=yes"));
}
示例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: from_instance_method_in_derived_class_show_correct_CallingType
public async Task from_instance_method_in_derived_class_show_correct_CallingType()
{
var entries = new List<LogEntry>();
using (Log.Events().Subscribe(entries.Add))
{
var widget = new InheritedWidget();
await widget.DoStuffAsync();
}
Assert.That(entries.Single(e => e.EventType == TraceEventType.Start).CallingType,
Is.EqualTo(typeof (InheritedWidget)));
Assert.That(entries.Single(e => e.EventType == TraceEventType.Stop).CallingType,
Is.EqualTo(typeof (InheritedWidget)));
}
示例7: from_instance_method_in_nested_class_show_correct_CallingMethod
public void from_instance_method_in_nested_class_show_correct_CallingMethod()
{
var log = new List<LogEntry>();
using (Log.Events().Subscribe(log.Add))
{
var widget = new BoundaryTests.NestedWidget();
widget.DoStuff();
}
Assert.That(log.Single(e => e.EventType == TraceEventType.Start).CallingMethod,
Is.EqualTo("DoStuff"));
Assert.That(log.Single(e => e.EventType == TraceEventType.Start).CallingMethod,
Is.EqualTo("DoStuff"));
}
示例8: from_instance_method_in_derived_class_show_correct_CallingMethod
public void from_instance_method_in_derived_class_show_correct_CallingMethod()
{
var entries = new List<LogEntry>();
using (Log.Events().Subscribe(entries.Add))
{
var widget = new InheritedWidget();
widget.DoStuff();
}
Assert.That(entries.Single(e => e.EventType == TraceEventType.Start).CallingMethod,
Is.EqualTo("DoStuff"));
Assert.That(entries.Single(e => e.EventType == TraceEventType.Stop).CallingMethod,
Is.EqualTo("DoStuff"));
}
示例9: AddUsersToRoles
public void AddUsersToRoles()
{
var users = new List<User>
{
new User {Username = "idpe", Email = "[email protected]", Password = "asd"},
new User {Username = "vladykx", Email = "[email protected]",Password = "asd"},
};
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
foreach (var user in users)
{
_Tests.Storage.CreateUser(user);
}
var usernames = users.Select(u => u.Username);
var roles = new List<Role> {Role.Teacher};
_Tests.Storage.AddUsersToRoles(usernames, roles);
foreach (var user in users)
{
Assert.IsTrue(_Tests.Storage.GetUserRoles(user.Username).Contains(roles.Single()));
}
_Tests.Storage.RemoveUsersFromRoles(usernames, roles);
}
示例10: Should_handle_TypeLoadException_and_find_1_event_listener
public void Should_handle_TypeLoadException_and_find_1_event_listener()
{
// Arrange
var log = new List<string>();
SecurityDoctor.Register(e => log.Add(e.Message));
var throwException = true;
const string expectedExceptionMessage = "Could not load type X.";
Func<Assembly, Type[]> assemblyTypeProvider = assembly =>
{
if (throwException)
{
throwException = false;
throw new TypeLoadException(expectedExceptionMessage);
}
return assembly.GetExportedTypes();
};
var scanner = new SecurityEventListenerScanner(true, assemblyTypeProvider);
var assemblies = new List<Assembly>
{
GetType().Assembly,
GetType().Assembly
};
// Act
var types = scanner.Scan(assemblies);
// Assert
Assert.That(types.Count(), Is.EqualTo(1));
Assert.That(log.Single(), Is.EqualTo(expectedExceptionMessage));
}
示例11: Should_produce_configuration_event_with_timing_when_event_listener_is_registered
public void Should_produce_configuration_event_with_timing_when_event_listener_is_registered()
{
// Arrange
const int expectedMilliseconds = 9;
var expectedResult = new { };
const string expectedMessage = "Message";
var events = new List<ISecurityEvent>();
SecurityDoctor.Register(events.Add);
// Act
var result = Publish.ConfigurationEvent(() =>
{
Thread.Sleep(expectedMilliseconds + 5);
return expectedResult;
}, r => expectedMessage);
// Assert
Assert.That(result, Is.EqualTo(expectedResult));
var @event = events.Single();
Assert.That(@event.CorrelationId, Is.EqualTo(SecurityConfigurator.CorrelationId));
Assert.That(@event.Message, Is.EqualTo(expectedMessage));
Assert.That(@event.CompletedInMilliseconds, Is.GreaterThanOrEqualTo(expectedMilliseconds));
}
示例12: AddExistingUsersToRoles
public void AddExistingUsersToRoles()
{
tests = UserManagementTests.Update();
var users = new List<User> {
new User { Username = "name1", Email = "[email protected]", Password = "123" },
new User { Username = "name2", Email = "[email protected]", Password = "123" },
};
foreach (var user in users)
{
this.tests.Storage.CreateUser(user);
}
var usernames = users.Select(u => u.Username);
var roles = new List<Role> { Role.Teacher };
this.tests.Storage.AddUsersToRoles(usernames, roles);
foreach (var user in users)
{
Assert.IsTrue(this.tests.Storage.GetUserRoles(user.Username).Contains(roles.Single()));
}
this.tests.Storage.RemoveUsersFromRoles(usernames, roles);
foreach (var user in users)
{
this.tests.Storage.DeleteUser(u => u.Username == user.Username);
}
}
示例13: AddExistingUsersToRoles
public void AddExistingUsersToRoles()
{
var users = new List<User>
{
new User {Username = "name1", Email = "[email protected]", Password = "123"},
new User {Username = "name2", Email = "[email protected]",Password = "123"},
};
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
foreach (var user in users)
{
_Tests.Storage.CreateUser(user);
}
var usernames = users.Select(u => u.Username);
var roles = new List<Role> {Role.Teacher};
_Tests.Storage.AddUsersToRoles(usernames, roles);
foreach (var user in users)
{
Assert.IsTrue(_Tests.Storage.GetUserRoles(user.Username).Contains(roles.Single()));
}
_Tests.Storage.RemoveUsersFromRoles(usernames, roles);
foreach (var user in users)
{
_Tests.Storage.DeleteUser(u => u.Username == user.Username);
}
}
示例14: Get_Payroll_For_2012_7_1
public void Get_Payroll_For_2012_7_1()
{
var adapter = new PayrollAdapter();
Payroll[] payrollItems = adapter.GetPayrollWeekEnding(DateTime.Parse("2012-7-1"));
List<Payroll> list = new List<Payroll>(payrollItems);
Payroll payroll = list.Single(x => x.Lastname == "Denton");
Assert.AreEqual(32, payroll.RegularHours);
}
示例15: messages_with_string
public void messages_with_string()
{
var stringCheck = AccessorPersistenceCheck.For<CheckTarget>(x => x.Name);
original.Name = "Jeremy";
persisted.Name = "Max";
var list = new List<string>();
stringCheck.CheckValue(original, persisted, list.Add);
list.Single().ShouldEqual("Name: original was 'Jeremy', but the persisted value was 'Max'");
}