本文整理汇总了C#中EasyNetQ.Tests.Mocking.MockBuilder类的典型用法代码示例。如果您正苦于以下问题:C# MockBuilder类的具体用法?C# MockBuilder怎么用?C# MockBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockBuilder类属于EasyNetQ.Tests.Mocking命名空间,在下文中一共展示了MockBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
connection = mockBuilder.Connection;
advancedBus = mockBuilder.Bus.Advanced;
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:7,代码来源:BlockedConnectionNotificationTests.cs
示例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();
}
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:32,代码来源:Given_a_PersistentConsumer.cs
示例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;
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:25,代码来源:When_a_request_is_sent.cs
示例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);
}
开发者ID:siniypin,项目名称:EasyNetQ,代码行数:7,代码来源:ExchangeQueueBindingTests.cs
示例6: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
var cancellation = mockBuilder.Bus.Respond<MyMessage, MyMessage>(x => new MyMessage());
cancellation.Dispose();
}
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:7,代码来源:When_a_requester_is_disposed.cs
示例7: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
var exchange = new Exchange("my_exchange");
advancedBus.ExchangeDelete(exchange);
}
开发者ID:stemarie,项目名称:EasyNetQ,代码行数:8,代码来源:ExchangeQueueBindingTests.cs
示例8: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
advancedBus = mockBuilder.Bus.Advanced;
var queue = new Topology.Queue("my_queue", false);
advancedBus.QueueDelete(queue);
}
开发者ID:xw616525957,项目名称:EasyNetQ,代码行数:8,代码来源:ExchangeQueueBindingTests.cs
示例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);
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:9,代码来源:When_autosubscribing_with_assembly_scanning.cs
示例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();
}
开发者ID:sezer-tunca-15below,项目名称:EasyNetQ,代码行数:11,代码来源:When_a_consumer_is_cancelled_by_the_user.cs
示例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");
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:13,代码来源:When_a_message_is_received.cs
示例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());
}
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:13,代码来源:ConventionsTests.cs
示例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);
}
开发者ID:KristofferV,项目名称:EasyNetQ,代码行数:14,代码来源:ExchangeQueueBindingTests.cs
示例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);
});
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:14,代码来源:When_IModel_throws.cs
示例16: SetUp
public void SetUp()
{
var conventions = new Conventions(new TypeNameSerializer())
{
ConsumerTagConvention = () => consumerTag
};
mockBuilder = new MockBuilder(x => x
.Register<IConventions>(_ => conventions)
//.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
);
mockBuilder.Bus.Subscribe<MyMessage>(subscriptionId, message => { });
}
开发者ID:autotagamerica,项目名称:EasyNetQ,代码行数:14,代码来源:SubscribeTests.cs
示例17: SetUp
public void SetUp()
{
mockBuilder = new MockBuilder();
var queue = new Queue("my_queue", false);
mockBuilder.Bus.Advanced.Consume(queue, (bytes, properties, arg3) => Task.Factory.StartNew(() => { }));
var are = new AutoResetEvent(false);
mockBuilder.EventBus.Subscribe<ConsumerModelDisposedEvent>(x => are.Set());
mockBuilder.Consumers[0].HandleBasicCancel("consumer_tag");
are.WaitOne(500);
}
开发者ID:KristofferV,项目名称:EasyNetQ,代码行数:15,代码来源:When_a_consumer_is_cancelled_by_the_broker.cs
示例18: SetUp
protected void SetUp()
{
ConsumerErrorStrategy = MockRepository.GenerateStub<IConsumerErrorStrategy>();
IConventions conventions = new Conventions(new TypeNameSerializer())
{
ConsumerTagConvention = () => ConsumerTag
};
MockBuilder = new MockBuilder(x => x
.Register(_ => conventions)
.Register(_ => ConsumerErrorStrategy)
//.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
);
AdditionalSetUp();
}
开发者ID:EricAtWork,项目名称:EasyNetQ,代码行数:16,代码来源:ConsumerTestBase.cs
示例19: SetUp
public void SetUp()
{
var customConventions = new Conventions
{
ExchangeNamingConvention = x => "CustomExchangeNamingConvention",
QueueNamingConvention = (x, y) => "CustomQueueNamingConvention",
TopicNamingConvention = x => "CustomTopicNamingConvention"
};
mockBuilder = new MockBuilder(x => x.Register<IConventions>(_ => customConventions));
using (var publishChannel = mockBuilder.Bus.OpenPublishChannel())
{
publishChannel.Publish(new TestMessage());
}
}
开发者ID:stemarie,项目名称:EasyNetQ,代码行数:16,代码来源:ConventionsTests.cs
示例20: SetUp
public void SetUp()
{
var conventions = new Conventions
{
RpcExchangeNamingConvention = () => "rpc_exchange",
RpcReturnQueueNamingConvention = () => "rpc_return_queue",
ConsumerTagConvention = () => "the_consumer_tag"
};
mockBuilder = new MockBuilder(x => x
.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
.Register<IConventions>(_ => conventions)
);
AdditionalSetup();
}
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:16,代码来源:RequestResponseTestBase.cs
注:本文中的EasyNetQ.Tests.Mocking.MockBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论