本文整理汇总了C#中EasyNetQ.Tests.Mocking.MockBuilder类的典型用法代码示例。如果您正苦于以下问题:C# MockBuilder类的具体用法?C# MockBuilder怎么用?C# MockBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockBuilder类属于EasyNetQ.Tests.Mocking命名空间,在下文中一共展示了MockBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
connection = mockBuilder.Connection;
advancedBus = mockBuilder.Bus.Advanced;
}
示例2: SetUp
public void SetUp()
{
eventBus = new EventBus();
internalConsumers = new List<IInternalConsumer>();
createConsumerCalled = 0;
mockBuilder = new MockBuilder();
queue = new Queue(queueName, false);
onMessage = (body, properties, info) => Task.Factory.StartNew(() => { });
persistentConnection = MockRepository.GenerateStub<IPersistentConnection>();
internalConsumerFactory = MockRepository.GenerateStub<IInternalConsumerFactory>();
internalConsumerFactory.Stub(x => x.CreateConsumer()).WhenCalled(x =>
{
var internalConsumer = MockRepository.GenerateStub<IInternalConsumer>();
internalConsumers.Add(internalConsumer);
createConsumerCalled++;
x.ReturnValue = internalConsumer;
}).Repeat.Any();
consumer = new PersistentConsumer(
queue,
onMessage,
persistentConnection,
internalConsumerFactory,
eventBus);
AdditionalSetup();
}
示例3: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
requestMessage = new TestRequestMessage();
responseMessage = new TestResponseMessage();
var correlationId = "";
mockBuilder.NextModel.Stub(x => x.BasicPublish(null, null, false, null, null))
.IgnoreArguments()
.WhenCalled(invocation =>
{
var properties = (IBasicProperties)invocation.Arguments[3];
correlationId = properties.CorrelationId;
});
var task = mockBuilder.Bus.RequestAsync<TestRequestMessage, TestResponseMessage>(requestMessage);
DeliverMessage(correlationId);
task.Wait();
responseMessage = task.Result;
}
示例4: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
var queue = new Queue("test_queue", false);
var are = new AutoResetEvent(false);
mockBuilder.Bus.Advanced.Consume<ITestMessageInterface>(queue, (message, info) => Task.Factory.StartNew(() =>
{
receivedMessage = message.Body;
are.Set();
}));
var publishedMessage = new Implementation { Text = "Hello Polymorphs!" };
var body = new JsonSerializer(new TypeNameSerializer()).MessageToBytes(publishedMessage);
var properties = new BasicProperties
{
Type = new TypeNameSerializer().Serialize(typeof(Implementation))
};
mockBuilder.Consumers[0].HandleBasicDeliver(
"consumer_tag",
0,
false,
"exchange",
"routing_key",
properties,
body
);
are.WaitOne(1000);
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:32,代码来源:When_a_polymorphic_message_is_delivered_to_the_consumer.cs
示例5: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
exchange = advancedBus.ExchangeDeclare("my_exchange", ExchangeType.Direct, passive:true);
}
示例6: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
var cancellation = mockBuilder.Bus.Respond<MyMessage, MyMessage>(x => new MyMessage());
cancellation.Dispose();
}
示例7: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
var exchange = new Exchange("my_exchange");
advancedBus.ExchangeDelete(exchange);
}
示例8: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
var queue = new Topology.Queue("my_queue", false);
advancedBus.QueueDelete(queue);
}
示例9: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
// mockBuilder = new MockBuilder(x => x.Register<IEasyNetQLogger, ConsoleLogger>());
var autoSubscriber = new AutoSubscriber(mockBuilder.Bus, "my_app");
autoSubscriber.Subscribe(GetType().Assembly);
}
示例10: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
var queue = new Queue("my_queue", false);
var cancelSubscription = mockBuilder.Bus.Advanced
.Consume(queue, (bytes, properties, arg3) => Task.Factory.StartNew(() => { }));
cancelSubscription.Dispose();
}
示例11: SetUp
public void SetUp()
{
//mockBuilder = new MockBuilder(x => x.Register<IEasyNetQLogger, ConsoleLogger>());
mockBuilder = new MockBuilder();
mockBuilder.Bus.Receive("the_queue", x => x
.Add<MyMessage>(message => deliveredMyMessage = message)
.Add<MyOtherMessage>(message => deliveredMyOtherMessage = message));
DeliverMessage("{ Text: \"Hello World :)\" }", "EasyNetQ.Tests.MyMessage:EasyNetQ.Tests");
DeliverMessage("{ Text: \"Goodbye Cruel World!\" }", "EasyNetQ.Tests.MyOtherMessage:EasyNetQ.Tests");
DeliverMessage("{ Text: \"Shoudn't get this\" }", "EasyNetQ.Tests.Unknown:EasyNetQ.Tests");
}
示例12: SetUp
public void SetUp()
{
typeNameSerializer = new TypeNameSerializer();
var customConventions = new Conventions(typeNameSerializer)
{
ExchangeNamingConvention = x => "CustomExchangeNamingConvention",
QueueNamingConvention = (x, y) => "CustomQueueNamingConvention",
TopicNamingConvention = x => "CustomTopicNamingConvention"
};
mockBuilder = new MockBuilder(x => x.Register<IConventions>(_ => customConventions));
mockBuilder.Bus.Publish(new TestMessage());
}
示例13: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
requestMessage = new TestRequestMessage();
mockBuilder.NextModel.Stub(x => x.BasicPublish(null, null, false, false, null, null))
.IgnoreArguments()
.WhenCalled(invocation =>
{
var properties = (IBasicProperties)invocation.Arguments[4];
_correlationId = properties.CorrelationId;
});
}
开发者ID:KristofferV,项目名称:EasyNetQ,代码行数:14,代码来源:When_a_request_is_sent_but_an_exception_is_thrown_by_responder.cs
示例14: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
queue = advancedBus.QueueDeclare(
"my_queue",
passive: false,
durable: false,
exclusive: true,
autoDelete: true,
perQueueTtl: 1000,
expires: 2000);
}
示例15: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder("host=localhost;timeout=1");
mockBuilder.NextModel
.Stub(x => x.ExchangeDeclare(null, null, false, false, null))
.IgnoreArguments()
.WhenCalled(x =>
{
var args = new ShutdownEventArgs(ShutdownInitiator.Peer, 320,
"CONNECTION_FORCED - Closed via management plugin");
throw new OperationInterruptedException(args);
});
}