本文整理汇总了C#中NUnit.Framework.List.Should方法的典型用法代码示例。如果您正苦于以下问题:C# List.Should方法的具体用法?C# List.Should怎么用?C# List.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Should方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OriginalThing_DoesThing
public void OriginalThing_DoesThing()
{
var strings = new List<string>();
new OriginalThing().DoesThing(strings);
strings.Should().NotBeEmpty();
strings.Should().HaveCount(1);
strings.ElementAt(0).Should().Contain("Original");
}
示例2: ProvidedOriginalThing_DoesThing
public void ProvidedOriginalThing_DoesThing()
{
var strings = new List<string>();
var thingServer = new Mock<IThingFactory>();
thingServer.Setup(ts => ts.GetThing()).Returns(new OriginalThing());
thingServer.Object.GetThing().DoesThing(strings);
strings.Should().NotBeEmpty();
strings.Should().HaveCount(1);
strings.ElementAt(0).Should().Contain("Original");
}
示例3: given_guarantor_with_no_first_name_when_validating_should_return_result_with_resource_value
public void given_guarantor_with_no_first_name_when_validating_should_return_result_with_resource_value()
{
var guarantor = new GuarantorWithGlobalResources { LastName = "Meinershagen" };
var results = new List<ValidationResult>();
guarantor.TryValidate(results);
results.Should().Contain(r => r.ErrorMessage == Resources.GuarantorFirstNameRequired);
results.Should().NotContain(r => r.ErrorMessage == Resources.ResourceManager.GetString("GuarantorLastNameRequired"));
}
示例4: TestAddToCollection
public void TestAddToCollection()
{
var collection = new List<string> {"a", "b", "c"};
var command = new AddToCollection<string>(collection, "d");
command.Execute();
collection.Should().Contain("d");
command.Undo();
collection.Should().NotContain("d");
}
示例5: given_valid_person_when_trying_to_validate_should_return_true_and_empty_results
public void given_valid_person_when_trying_to_validate_should_return_true_and_empty_results()
{
var results = new List<ValidationResult>();
var complexPerson = new PersonWithBuiltInValidation{FirstName = "Todd", LastName = "Meinershagen", EmailAddress = "[email protected]"};
complexPerson.TryValidate(results).Should().BeTrue();
results.Should().BeEmpty();
var simplePerson = new PersonWithCustomValidation { FirstName = "Todd", LastName = "Meinershagen", EmailAddress = "[email protected]" };
simplePerson.TryValidate(results).Should().BeTrue();
results.Should().BeEmpty();
}
示例6: TestExecute
public void TestExecute()
{
var list = new List<string> {"a", "b", "c"};
var command = new ReplaceInList<string>(list, "b", "x");
command.Execute();
list.Should().Equal("a", "x", "c");
command.Undo();
list.Should().Equal("a", "b", "c");
}
示例7: TestAddIfNew
public void TestAddIfNew()
{
var list = new List<string> {"a", "b", "c"};
list.AddIfNew("b").Should().BeFalse();
list.Should().Equal("a", "b", "c");
list.AddIfNew("d").Should().BeTrue();
list.Should().Equal("a", "b", "c", "d");
list.Invoking(x => x.RemoveLast(-1)).ShouldThrow<ArgumentOutOfRangeException>();
}
示例8: ProvidedOriginalThing_DoesThing
public void ProvidedOriginalThing_DoesThing()
{
var strings = new List<string>();
var factory = new OriginalThingFactory();
var originalThing = factory.GetThing();
originalThing.Should().BeOfType<OriginalThing>();
originalThing.DoesThing(strings);
strings.Should().NotBeEmpty();
strings.Should().HaveCount(1);
strings.ElementAt(0).Should().Contain("Original");
}
示例9: ProvidedFakeThing_DoesThing
public void ProvidedFakeThing_DoesThing()
{
var strings = new List<string>();
var factory = new FakeThingFactory();
var fakeThing = factory.GetThing();
fakeThing.Should().BeOfType<FakeThing>();
fakeThing.DoesThing(strings);
strings.Should().NotBeEmpty();
strings.Should().HaveCount(1);
strings.ElementAt(0).Should().Contain("Fake");
}
示例10: Activity_is_notified_when_a_command_is_scheduled
public async Task Activity_is_notified_when_a_command_is_scheduled()
{
// arrange
var order = CommandSchedulingTests_EventSourced.CreateOrder();
var activity = new List<ICommandSchedulerActivity>();
using (Configuration.Current
.Container
.Resolve<SqlCommandScheduler>()
.Activity
.Subscribe(activity.Add))
{
// act
order.Apply(new ShipOn(Clock.Now().Add(TimeSpan.FromDays(2))));
await orderRepository.Save(order);
//assert
activity.Should()
.ContainSingle(a => a.ScheduledCommand
.IfTypeIs<IScheduledCommand<Order>>()
.Then(c => c.TargetId == order.Id.ToString())
.ElseDefault() &&
a is CommandScheduled);
}
}
示例11: given_trip_with_date_not_after_today_when_checking_is_valid_should_be_false
public void given_trip_with_date_not_after_today_when_checking_is_valid_should_be_false()
{
var results = new List<ValidationResult>();
var trip = new Trip { Date = 23.November(1972) };
trip.TryValidate(results).Should().BeFalse();
results.Should().NotBeEmpty();
}
示例12: ArgumentStaticPassedByReference
public void ArgumentStaticPassedByReference()
{
var assignTo = new List<string>();
var expectedList = new[] { "newItemForStatic" };
typeof(TestClass).Invoke("ProtectedStaticMethod", NoTypeArguments, assignTo);
assignTo.Should().BeEquivalentTo(expectedList).And.HaveSameCount(expectedList);
}
示例13: ArgumentInstancePassedByReference
public void ArgumentInstancePassedByReference()
{
var assignTo = new List<string>();
var expectedList = new[] { "newItem" };
new TestClass().Call("ProtectedMethod", null, assignTo);
assignTo.Should().BeEquivalentTo(expectedList).And.HaveSameCount(expectedList);
}
示例14: TestMatch1
public void TestMatch1()
{
var filter = new SubstringFilter("Foobar", true);
var matches = new List<LogLineMatch>();
new Action(() => filter.Match(new LogLine(0, 0, null, LevelFlags.All), matches)).ShouldNotThrow();
matches.Should().BeEmpty();
}
示例15: when_attempting_to_restore_an_externally_tracked_list
public void when_attempting_to_restore_an_externally_tracked_list()
{
var mementor = new Mementor(isEnabled: true);
var collection = new List<string>();
var item = "hey!";
mementor.ElementAdd(collection, item);//this is an extension method? Oh I see, he didnt want to put custom-list logic on Mementor. Nice.
//it also doesnt actually add the element to the list:
collection.Add(item);
collection.Should().HaveCount(1);
mementor.Undo();
//hmm, so it expects the caller to do the Add but it will handle the remove?
collection.Should().BeEmpty();
}