Exemplo n.º 1
0
        public void CanSendOldFormat()
        {
            _bus.Advanced.Routing.Send(_oldEndpoint, new OldSchoolMessage { KeyChar = "g" }).Wait();

            using (var queue = new MessageQueue(MsmqUtil.GetFullPath(_oldEndpoint)))
            {
                var message = queue.GetNextMessage();

                using (var streamReader = new StreamReader(message.BodyStream, Encoding.UTF7))
                {
                    var jsonText = streamReader.ReadToEnd();

                    Assert.That(jsonText.ToNormalizedJson(), Is.EqualTo(ValidLegacyRebusMessage.ToNormalizedJson()));
                }

                var headers = message.DeserializeHeaders();

                Console.WriteLine(@"Headers:
            {0}", string.Join(Environment.NewLine, headers.Select(kvp => $"    {kvp.Key}: {kvp.Value}")));

                Assert.That(headers["rebus-msg-id"], Is.Not.Empty);
                Assert.That(headers["rebus-content-type"], Is.EqualTo("text/json"));
                Assert.That(headers["rebus-encoding"], Is.EqualTo("utf-7"));
                Assert.That(headers["rebus-return-address"], Is.EqualTo(_newEndpoint + "@" + Environment.MachineName));
            }
        }
Exemplo n.º 2
0
        public async Task CanSubcribeWithOldSchoolSubscriptionRequest()
        {
            await _bus.Subscribe<string>();

            await Task.Delay(500);

            using (var queue = new MessageQueue(MsmqUtil.GetFullPath(_oldEndpoint)))
            {
                var message = queue.GetNextMessage();
                var headers = message.DeserializeHeaders();

                using (var streamReader = new StreamReader(message.BodyStream, Encoding.UTF7))
                {
                    var jsonText = streamReader.ReadToEnd();

                    Assert.That(jsonText.ToNormalizedJson(), Is.EqualTo(ExpectedStringSubscriptionRequest.ToNormalizedJson()));
                }

            }
        }