Exemplo n.º 1
0
        public void MessageQueuedForReceive_IsNotLogged_IfReceiveAborts()
        {
            ManualResetEvent wait = new ManualResetEvent(false);

            var sender = new FakeSender
            {
                Destination = new Endpoint("localhost", 23457),
                Messages    = new[]
                {
                    new Message
                    {
                        Id =
                            new MessageId
                        {
                            MessageIdentifier = Guid.NewGuid(),
                            SourceInstanceId  = Guid.NewGuid()
                        },
                        SentAt = DateTime.Now,
                        Queue  = "h",
                        Data   = new byte[] { 1, 2, 4, 5 }
                    }
                }
            };

            sender.SendCompleted += () => wait.Set();
            var logger = new RecordingLogger();

            sender.Send();
            wait.WaitOne(TimeSpan.FromSeconds(1));
            Wait.Until(() => logger.MessagesQueuedForReceive.Any(),
                       timeoutInMilliseconds: 1000)
            .ShouldBeFalse();
        }
Exemplo n.º 2
0
        public void MessageQueuedForReceive_EventNotRaised_IfReceiveAborts()
        {
            ManualResetEvent wait = new ManualResetEvent(false);

            using (var sender = new FakeSender
            {
                Destination = new Endpoint("localhost", 23457),
                FailToAcknowledgeReceipt = true,
                Messages = new[] { new Message
                                   {
                                       Id = new MessageId {
                                           MessageIdentifier = Guid.NewGuid(), SourceInstanceId = Guid.NewGuid()
                                       },
                                       SentAt = DateTime.Now,
                                       Queue = "h",
                                       Data = new byte[] { 1, 2, 4, 5 }
                                   } }
            })
            {
                sender.SendCompleted += () => wait.Set();
                using (var receiver = SetupReciever())
                {
                    receiver.MessageQueuedForReceive += RecordMessageEvent;

                    sender.Send();
                    wait.WaitOne();

                    Thread.Sleep(1000);

                    receiver.MessageQueuedForReceive -= RecordMessageEvent;
                }
            }

            Assert.Null(messageEventArgs);
        }
Exemplo n.º 3
0
        static string address = "25.3.124.57"; // адрес сервера
        static void Main(string[] args)
        {
            var a = new FakeSender(address, port);

            a.Send();
            a.DataToSend.Add(Encoding.Unicode.GetBytes("ads"));
            while (true)
            {
            }
        }