本文整理汇总了C#中TestMessage类的典型用法代码示例。如果您正苦于以下问题:C# TestMessage类的具体用法?C# TestMessage怎么用?C# TestMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestMessage类属于命名空间,在下文中一共展示了TestMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ShouldForwardPolymorphicMessage
public void ShouldForwardPolymorphicMessage()
{
var handler = new TestEventHandler();
var message = new TestMessage();
EventFns.Forward(handler, message);
Assert.IsTrue(handler.IMessageHandled, "Message should have been handled");
}
开发者ID:ValdimarThor,项目名称:Cocktail,代码行数:7,代码来源:EventHandlerUnitTests.cs
示例2: ServiceQueue_1_Writer_1_Reader
public void ServiceQueue_1_Writer_1_Reader(ServiceQueueRotationAlgorithm algorithm)
{
using (var serviceQueue = new ServiceQueue(algorithm))
using (var reader = new ServiceQueueReader())
using (var writer = new ServiceQueueWriter())
{
var endpoint = GetEndpoint();
serviceQueue.Bind(endpoint);
var counterSignal = new CounterSignal(NumberOfMessages, 0);
reader.MessageReceived += (s, m) => counterSignal.Increment();
reader.Connect(endpoint);
writer.Connect(endpoint);
var messageSent = new TestMessage();
var sw = Stopwatch.StartNew();
for (var i = 0; i < NumberOfMessages; i++)
{
writer.SendMessage(messageSent);
}
Assert.IsTrue(counterSignal.Wait(TimeOut), "Timeout waiting for message");
sw.Stop();
Assert.Inconclusive("{0} elapsed reading {1} messages ({2:N0} per second)", sw.Elapsed, NumberOfMessages, NumberOfMessages / sw.Elapsed.TotalSeconds);
}
}
开发者ID:tleviathan,项目名称:redfoxmq,代码行数:29,代码来源:ServiceQueueBenchmarks.cs
示例3: SerialiseMessageWithGuid
public void SerialiseMessageWithGuid()
{
var message = new TestMessage { Id = Guid.Parse("C50DDB56-B827-46E3-9D7D-ACB701882624") };
var serialisedMessage = this.componentUnderTest.Serialise(message);
Assert.That(serialisedMessage, Is.EqualTo(MessageWithGuid));
}
开发者ID:hariharanpalani,项目名称:service-bus,代码行数:7,代码来源:SerialiseShould.cs
示例4: Should_properly_arrive_at_the_destination
public void Should_properly_arrive_at_the_destination()
{
var serviceUri = new Uri("net.pipe://localhost/pipe");
string pipeName = "test";
var future = new Future<TestMessage>();
var message = new TestMessage
{
Id = Guid.NewGuid(),
Name = "Alpha",
};
UntypedChannel adapter = new ChannelAdapter();
using (var remote = new WcfChannelHost(new SynchronousFiber(), adapter, serviceUri, pipeName))
{
using (adapter.Connect(x =>
{
x.AddConsumerOf<TestMessage>()
.UsingConsumer(m => future.Complete(m));
}))
{
var client = new WcfChannelProxy(new SynchronousFiber(), serviceUri, pipeName);
client.Send(message);
future.WaitUntilCompleted(2.Seconds()).ShouldBeTrue();
}
}
future.Value.ShouldNotBeNull();
future.Value.ShouldEqual(message);
future.Value.ShouldNotBeTheSameAs(message);
}
开发者ID:Nangal,项目名称:Stact,代码行数:33,代码来源:RemoteChannel_Specs.cs
示例5: One_Publisher_One_Subscriber_Batch_Broadcast
public void One_Publisher_One_Subscriber_Batch_Broadcast()
{
using (var publisher = new Publisher())
using (var subscriber = new Subscriber())
{
var endpoint = GetEndpoint();
publisher.Bind(endpoint);
subscriber.Connect(endpoint);
Thread.Sleep(100);
var counterSignal = new CounterSignal(NumberOfMessagesToReceive);
subscriber.MessageReceived += (s, m) => counterSignal.Increment();
var messageSent = new TestMessage();
var batch = new List<TestMessage>();
for (var i = 0; i < NumberOfMessagesToReceive; i++)
batch.Add(messageSent);
var sw = Stopwatch.StartNew();
publisher.Broadcast(batch);
Assert.IsTrue(counterSignal.Wait(TimeOut), "Timeout waiting for message");
sw.Stop();
Assert.Inconclusive("{0} elapsed reading {1} messages ({2:N0} per second)", sw.Elapsed, NumberOfMessagesToReceive, NumberOfMessagesToReceive / sw.Elapsed.TotalSeconds);
}
}
开发者ID:tleviathan,项目名称:redfoxmq,代码行数:28,代码来源:PublisherSubscriberBenchmarks.cs
示例6: SetsTheValueOfTheMessageProperty
public void SetsTheValueOfTheMessageProperty()
{
var message = new TestMessage();
var routeResult = new RouteResult(message, null);
Assert.That(routeResult.Message, Is.SameAs(message));
}
开发者ID:peteraritchie,项目名称:Rock.Messaging,代码行数:8,代码来源:RouteResultTests.cs
示例7: GetInstance_NullInstanceContext
public void GetInstance_NullInstanceContext()
{
var data = new ServiceImplementationData();
var container = new ContainerBuilder().Build();
var provider = new AutofacInstanceProvider(container, data);
var message = new TestMessage();
Assert.Throws<ArgumentNullException>(() => provider.GetInstance(null, message));
}
开发者ID:RoymanJing,项目名称:Autofac,代码行数:8,代码来源:AutofacInstanceProviderFixture.cs
示例8: send_waiting_message_fires_event_hooks
public void send_waiting_message_fires_event_hooks ()
{
var msg = new TestMessage();
((SenderNode)_subject).SendMessage(msg);
_eventHook1.Received().MessageSent(msg);
_eventHook2.Received().MessageSent(msg);
}
开发者ID:i-e-b,项目名称:SevenDigital.Messaging,代码行数:8,代码来源:SenderNodeTests.cs
示例9: TestBroker
public void TestBroker()
{
TestMessage message = new TestMessage {Id = Guid.NewGuid(), Text = "Some text"};
MessageBroker broker = new MessageBroker();
broker.Write(message);
TestMessage readMessage = broker.Read<TestMessage>(0);
Assert.IsNotNull(readMessage);
}
开发者ID:mikael-kuhn,项目名称:mscourse,代码行数:8,代码来源:UnitTest1.cs
示例10: Should_be_able_to_serialize_and_deserialize_a_message
public void Should_be_able_to_serialize_and_deserialize_a_message()
{
var initialMessage = new TestMessage {Text = "Hello!"};
var serializedMessage = serializer.MessageToBytes(initialMessage);
var deserializedMessage = serializer.BytesToMessage<TestMessage>(serializedMessage);
deserializedMessage.Text.ShouldEqual(initialMessage.Text);
}
开发者ID:ngbrown,项目名称:EasyNetQ,代码行数:8,代码来源:BinarySerializerTests.cs
示例11: Definition_should_allow_to_retrieve_proper_correlation_id
public void Definition_should_allow_to_retrieve_proper_correlation_id()
{
var message = new TestMessage { FirstId = Guid.NewGuid(), SecondId = Guid.NewGuid() };
var def1 = MessageDefinition.Create<TestMessage>(m => m.FirstId);
var def2 = MessageDefinition.Create<TestMessage>(m => m.SecondId);
Assert.That(def1.GetCorrelationId(message), Is.EqualTo(message.FirstId), "It should use FirstId");
Assert.That(def2.GetCorrelationId(message), Is.EqualTo(message.SecondId), "It should use SecondId");
}
开发者ID:Suremaker,项目名称:SLAMonitor,代码行数:9,代码来源:MessageDefinitionTests.cs
示例12: WaitsForFirstMessage
public async Task WaitsForFirstMessage() {
var task = this.EventManager.WaitFor<TestMessage, SecondTestMessage>();
var testMessage = new TestMessage();
this.MessageBus.Send(testMessage);
this.React();
var result = await task;
Assert.AreEqual(result, testMessage);
}
开发者ID:ttsvetanov,项目名称:Eventing,代码行数:10,代码来源:EventManagerTests.cs
示例13: Publish_calls_the_method_on_subscriber
public void Publish_calls_the_method_on_subscriber()
{
var simplePublishWay = new SimpleDispatcher();
var message = new TestMessage();
var handler = new TestHandler();
simplePublishWay.Invoke(message, handler);
Assert.That(handler.TestMessage, Is.SameAs(message));
}
开发者ID:solyutor,项目名称:Solyutor.EventPublisher,代码行数:10,代码来源:SimplePublishWayTest.cs
示例14: SerialiseAndDeserialiseMessage
public void SerialiseAndDeserialiseMessage()
{
var componentUnderTest = new JsonMessageSerialiser();
var message = new TestMessage();
var serialisedMessage = componentUnderTest.Serialise(message);
var deserialisedMessage = componentUnderTest.Deserialise(serialisedMessage, typeof(TestMessage));
Assert.That(deserialisedMessage, Is.Not.Null);
}
开发者ID:hariharanpalani,项目名称:service-bus,代码行数:10,代码来源:JsonMessageSerialiserShould.cs
示例15: ExpectExceptionForUnreadableData
public void ExpectExceptionForUnreadableData()
{
var message = new TestMessage { content = "This message cannot be resolved!", ID = 0 };
var memoryStream = new MemoryStream(new byte[64]);
var binaryWriter = new BinaryWriter(memoryStream);
binaryWriter.Write(BinaryDataExtensions.ToByteArray(message));
memoryStream.Position = 0;
var binaryReader = new BinaryReader(memoryStream);
Assert.Throws<TypeLoadException>(() => binaryReader.Create());
}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:10,代码来源:BinaryDataExtensionsTests.cs
示例16: Should_no_throw_if_no_dispatcher_found_and_set_to_ignore
public void Should_no_throw_if_no_dispatcher_found_and_set_to_ignore()
{
var assignee = new SimpleSubscriber();
var handler = new TestHandler();
var message = new TestMessage();
var publisher = new Publisher(new PublisherSettings{IgnoreNoDispatcher = true},assignee, new[] { new SimpleDispatcher(new Rule(x => false)) });
assignee.Subscribe(handler);
Should.NotThrow(() => publisher.Publish(message));
}
开发者ID:Codestellation,项目名称:Emisstar,代码行数:11,代码来源:PublisherTests.cs
示例17: AssertDispatchesCall
private static void AssertDispatchesCall(SynchronizationContextDispatcher dispatcher)
{
var handler = new TestHandler();
var message = new TestMessage();
dispatcher.Invoke(message, handler);
handler.Called.WaitOne(1000);
Assert.That(handler.TestMessage, Is.SameAs(message));
}
开发者ID:solyutor,项目名称:Solyutor.EventPublisher,代码行数:11,代码来源:SynchronizationContextPublishWayTest.cs
示例18: Reply_ShouldContainMessageInRepliedMessages
public async Task Reply_ShouldContainMessageInRepliedMessages()
{
var context = new TestableMessageHandlerContext();
var messageInstance = new TestMessage();
var publishOptions = new ReplyOptions();
await context.Reply(messageInstance, publishOptions);
Assert.AreEqual(1, context.RepliedMessages.Length);
Assert.AreSame(messageInstance, context.RepliedMessages[0].Message);
Assert.AreSame(publishOptions, context.RepliedMessages[0].Options);
}
开发者ID:Particular,项目名称:NServiceBus,代码行数:12,代码来源:TestableMessageHandlerContextTests.cs
示例19: Send_ShouldContainMessageInSentMessages
public async Task Send_ShouldContainMessageInSentMessages()
{
var context = new TestableMessageHandlerContext();
var messageInstance = new TestMessage();
var sendOptions = new SendOptions();
await context.Send(messageInstance, sendOptions);
Assert.AreEqual(1, context.SentMessages.Length);
Assert.AreSame(messageInstance, context.SentMessages[0].Message);
Assert.AreSame(sendOptions, context.SentMessages[0].Options);
}
开发者ID:Particular,项目名称:NServiceBus,代码行数:12,代码来源:TestableMessageHandlerContextTests.cs
示例20: When_I_Send_A_Message
private void When_I_Send_A_Message()
{
try
{
_testMessage = new TestMessage();
_messageBus.Send(_testMessage);
}
catch (NoHandlerException e)
{
_expectedException = e;
}
}
开发者ID:philpursglove,项目名称:DDDEastAnglia,代码行数:12,代码来源:Given_That_The_TestMessageHandler_Has_Been_Registered_The_SimpleMessageBus_Should.cs
注:本文中的TestMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论