本文整理汇总了C#中NUnit.Framework.List.ShouldBe方法的典型用法代码示例。如果您正苦于以下问题:C# List.ShouldBe方法的具体用法?C# List.ShouldBe怎么用?C# List.ShouldBe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.ShouldBe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanPublishWithinTransactionScopeWhenProvidingDefaultConnectionHolder
public void CanPublishWithinTransactionScopeWhenProvidingDefaultConnectionHolder()
{
// arrange
var subscriptionStorage = new SqlServerSubscriptionStorage(ConnectionString, SubscriptionsTableName);
subscriptionStorage.EnsureTableIsCreated();
var publisher = CreateBus(PublisherInputQueueName, subscriptionStorage);
var subReceivedEvents = new List<int>();
var sub = CreateBus(SubscriberInputQueueName, subscriptionStorage)
.Handle<SomeEvent>(e => subReceivedEvents.Add(e.EventNumber));
sub.Bus.Subscribe<SomeEvent>();
// act
Thread.Sleep(1.Seconds());
using (var scope = new TransactionScope())
{
publisher.Bus.Publish(new SomeEvent { EventNumber = 1 });
scope.Complete();
}
Thread.Sleep(1.Seconds());
// assert
subReceivedEvents.ShouldBe(new[] { 1 }.ToList());
}
示例2: given_zero_test_data_rows_should_return_same_scenarios
public void given_zero_test_data_rows_should_return_same_scenarios()
{
scenarios.ForEach(s => (s as Scenario).TestDataRows = new List<TestData>());
built = builder.Build(scenarios);
built.ShouldBe(scenarios);
}
示例3: WhenFoo
public void WhenFoo()
{
var foo = new Foo();
IList<IFoo> a = new List<IFoo>();
a.Add(foo);
a.ShouldBe(new IFoo[] { foo });
}
示例4: ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldChuckAWobbly
public void ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldChuckAWobbly()
{
var list = new List<int>();
var equalListWithDifferentRef = new List<int>();
list.ShouldBe(equalListWithDifferentRef);
ShouldChuck(() => list.ShouldBeSameAs(equalListWithDifferentRef));
list.ShouldNotBeSameAs(equalListWithDifferentRef);
}
示例5: ShouldCopyItems
public void ShouldCopyItems()
{
var list1 = new List<int> {2, 3, 4};
var list2 = new List<int> {1, 3, 5};
list1.CopyItemsFrom(list2);
list1.ShouldBe(new List<int> {3, 1, 5});
}
示例6: ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldThrow
public void ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldThrow()
{
var list = new List<int> { 1, 2, 3 };
var equalListWithDifferentRef = new List<int> { 1, 2, 3 };
list.ShouldBe(equalListWithDifferentRef);
Should.Error(
() => list.ShouldBeSameAs(equalListWithDifferentRef),
"() => list should be same as [1, 2, 3] but was [1, 2, 3] difference [1, 2, 3]"
);
list.ShouldNotBeSameAs(equalListWithDifferentRef);
}
示例7: ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldFail
public void ShouldBeSameAs_WhenEqualListsButDifferentReferences_ShouldFail()
{
var list = new List<int> { 1, 2, 3 };
var equalListWithDifferentRef = new List<int> { 1, 2, 3 };
list.ShouldBe(equalListWithDifferentRef);
TestHelper.ShouldFailWithError(
() => list.ShouldBeSameAs(equalListWithDifferentRef),
"list should be same as {1, 2, 3} but was {1, 2, 3} difference {1, 2, 3}"
);
list.ShouldNotBeSameAs(equalListWithDifferentRef);
}
示例8: Docs
public void Docs()
{
var apu = new Person { Name = "Apu" };
var homer = new Person { Name = "Homer" };
var skinner = new Person { Name = "Skinner" };
var barney = new Person { Name = "Barney" };
var theBeSharps = new List<Person> { homer, skinner, barney };
TestHelpers.Should.Error(() =>
theBeSharps.ShouldBe(new[] {apu, homer, skinner, barney}),
@"theBeSharps
should be
[Apu, Homer, Skinner, Barney]
but was
[Homer, Skinner, Barney]
difference
[*Homer *, *Skinner *, *Barney *, *]");
}
示例9: ordering_follows_specification
public void ordering_follows_specification()
{
var expected = new List<SemanticVersion>
{
v("1.0.0-alpha"),
v("1.0.0-alpha.1"),
v("1.0.0-beta.2"),
v("1.0.0-beta.11"),
v("1.0.0-rc.1"),
v("1.0.0-rc.1+build.1"),
v("1.0.0"),
v("1.0.0+0.3.7"),
v("1.3.7+build"),
v("1.3.7+build.2.b8f12d7"),
v("1.3.7+build.11.e0f985a")
};
var actual = new List<SemanticVersion>(expected);
actual.Sort();
actual.ShouldBe(expected);
}
示例10: SeeIfItWorks
public void SeeIfItWorks(int workers, int iterations)
{
var receivedStrings = new List<string>();
using (var adapter1 = new BuiltinContainerAdapter())
using (var adapter2 = new BuiltinContainerAdapter())
{
adapter1.Handle<ThisIsJustSomeRandomTestMessage>(msg => receivedStrings.Add(msg.WithSomethingInside));
var bus1 =
(RebusBus) Configure.With(adapter1)
.Transport(x => x.UseRabbitMq(ConnectionString, InputQueueName1, ErrorQueueName)
.ManageSubscriptions())
.CreateBus();
bus1.Start(workers);
bus1.Subscribe<ThisIsJustSomeRandomTestMessage>();
var bus2 =
(RebusBus) Configure.With(adapter2)
.Transport(x => x.UseRabbitMq(ConnectionString, InputQueueName2, ErrorQueueName)
.ManageSubscriptions())
.CreateBus();
bus2.Start(1);
var messageCounter = 1;
iterations.Times(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(2));
bus2.Publish(new ThisIsJustSomeRandomTestMessage{WithSomethingInside=string.Format("Message number {0}", messageCounter++)});
});
Thread.Sleep(TimeSpan.FromSeconds(5));
}
receivedStrings.ShouldBe(Enumerable.Range(1, iterations)
.Select(i => string.Format("Message number {0}", i))
.ToList());
}
示例11: CanSubscribeAndUnsubscribeWithAdvancedApi
public void CanSubscribeAndUnsubscribeWithAdvancedApi()
{
// arrange
var publisher = CreateBus(PublisherInputQueueName, new HandlerActivatorForTesting()).Start(1);
var sub1ReceivedEvents = new List<int>();
var sub2ReceivedEvents = new List<int>();
var sub1 = CreateBus(Subscriber1InputQueueName,
new HandlerActivatorForTesting()
.Handle<SomeEvent>(e => sub1ReceivedEvents.Add(e.EventNumber))).Start(1);
var sub2 = CreateBus(Subscriber2InputQueueName,
new HandlerActivatorForTesting()
.Handle<SomeEvent>(e => sub2ReceivedEvents.Add(e.EventNumber))).Start(1);
// act
sub1.Advanced.Routing.Subscribe(typeof(SomeEvent));
sub2.Advanced.Routing.Subscribe(typeof(SomeEvent));
Thread.Sleep(1.Seconds());
publisher.Publish(new SomeEvent{EventNumber=1});
publisher.Batch.Publish(new[] { new SomeEvent { EventNumber = 2 }, new SomeEvent { EventNumber = 3 } });
Thread.Sleep(1.Seconds());
sub1.Advanced.Routing.Unsubscribe(typeof(SomeEvent));
Thread.Sleep(1.Seconds());
publisher.Publish(new SomeEvent { EventNumber = 4 });
publisher.Batch.Publish(new[] { new SomeEvent { EventNumber = 5 }, new SomeEvent { EventNumber = 6 } });
Thread.Sleep(200);
// assert
sub1ReceivedEvents.ShouldBe(new[] {1, 2, 3}.ToList());
sub2ReceivedEvents.ShouldBe(new[] {1, 2, 3, 4, 5, 6}.ToList());
}
示例12: ShouldBeAbleToInterceptWithMultipleInterceptors
public void ShouldBeAbleToInterceptWithMultipleInterceptors()
{
var list = new List<int>();
var proxy = new ProxyBase
{
backingObject = new InterceptedFace(list),
interceptors = new IInterceptor[] { new TailInterceptor(list), new FaceInterceptor(list) }
};
var invocation = new Invocation(proxy.interceptors);
invocation.Start(typeof(IFace).GetMethods()[0], new object[0], args => (proxy.backingObject as IFace).Foo());
invocation.ReturnValue.ShouldBe(10);
list.ShouldBe(new List<int>{0,1,2,3,4});
}
示例13: List
public void List()
{
var result = new List<string> { "hello", "world" }.ToJson();
result.ShouldBe("[\"hello\", \"world\"]");
}
示例14: ShouldPutItAllTogetherWhenPassedAType
public void ShouldPutItAllTogetherWhenPassedAType()
{
var list = new List<int>();
var blah = (IFace)generator.GenerateProxy(typeof(IFace), new InterceptedFace(list), new IInterceptor[] { new TailInterceptor(list), new FaceInterceptor(list) });
blah.Foo().ShouldBe(10);
list.ShouldBe(new List<int> { 0, 1, 2, 3, 4 });
}
示例15: ShouldPutItAllTogether
public void ShouldPutItAllTogether()
{
var list = new List<int>();
var blah = generator.GenerateProxy<IFace>(new InterceptedFace(list), new IInterceptor[] {new TailInterceptor(list), new FaceInterceptor(list)});
blah.Foo().ShouldBe(10);
list.ShouldBe(new List<int>{0,1,2,3,4});
}