本文整理汇总了C#中TestMessage类的典型用法代码示例。如果您正苦于以下问题:C# TestMessage类的具体用法?C# TestMessage怎么用?C# TestMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestMessage类属于命名空间,在下文中一共展示了TestMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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);
}
}
示例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));
}
示例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);
}
示例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);
}
}
示例6: SetsTheValueOfTheMessageProperty
public void SetsTheValueOfTheMessageProperty()
{
var message = new TestMessage();
var routeResult = new RouteResult(message, null);
Assert.That(routeResult.Message, Is.SameAs(message));
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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));
}
示例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);
}
示例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());
}