public void Bus_SendAsync_Nominal()
        {
            QueueReader.CleanQueueAsync(SERVICENAME).Wait();

            var id = Guid.NewGuid();

            var message = new TestMessage()
            {
                SomeData = id.ToString()
            };

            var  serializer = new JSONSerializer();
            var  publisher  = new Mock <IPublishEvents>();
            IBus bus        = new Bus(serializer, new AzureStorageQueueSendTransport(serializer), publisher.Object);

            bus.Context = new AFBusMessageContext();

            bus.SendAsync(message, SERVICENAME).Wait();

            var stringMessage = QueueReader.ReadOneMessageFromQueueAsync(SERVICENAME).Result;

            var finalMessageEnvelope = JsonConvert.DeserializeObject <AFBusMessageEnvelope>(stringMessage, new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
            });

            var finalMessage = JsonConvert.DeserializeObject <TestMessage>(finalMessageEnvelope.Body, new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
            });

            Assert.IsTrue(id.ToString() == finalMessage.SomeData);
        }
        public static void AssemblyInit(TestContext context)
        {
            QueueReader.CleanQueueAsync(SERVICENAME).Wait();

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
            startInfo.FileName    = "cmd.exe";
            startInfo.Arguments   = @"/c C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe clear all";
            process.StartInfo     = startInfo;
            process.Start();

            process.WaitForExit();
        }
        public void Bus_SendAsync_DelayedMessage()
        {
            QueueReader.CleanQueueAsync(SERVICENAME).Wait();

            var message = new TestMessage()
            {
                SomeData = "delayed"
            };

            var  serializer = new JSONSerializer();
            var  publisher  = new Mock <IPublishEvents>();
            IBus bus        = new Bus(serializer, new AzureStorageQueueSendTransport(serializer), publisher.Object);

            bus.Context = new AFBusMessageContext();

            var before      = DateTime.Now;
            var timeDelayed = new TimeSpan(0, 0, 5);

            bus.SendAsync(message, SERVICENAME, timeDelayed).Wait();

            string stringMessage = null;

            do
            {
                stringMessage = QueueReader.ReadOneMessageFromQueueAsync(SERVICENAME).Result;
            }while (string.IsNullOrEmpty(stringMessage));

            var after = DateTime.Now;

            var finalMessageEnvelope = JsonConvert.DeserializeObject <AFBusMessageEnvelope>(stringMessage, new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
            });

            var finalMessage = JsonConvert.DeserializeObject <TestMessage>(finalMessageEnvelope.Body, new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
            });

            Assert.IsTrue(after - before > timeDelayed, "Delay failed");
        }
Beispiel #4
0
        public void BigMessage_Bug_Small_After_Big_Mixes_Message_In_File_Flag()
        {
            BlobReader.DeleteFilesAsync().Wait();
            QueueReader.CleanQueueAsync(SERVICENAME).Wait();

            InvocationCounter.Instance.Reset();

            var container = new HandlersContainer(SERVICENAME);

            var message = new BigMessage2();

            message.Data = new string('*', 66000);

            SendOnlyBus.SendAsync(message, SERVICENAME).Wait();

            var stringMessage = QueueReader.ReadOneMessageFromQueueAsync(SERVICENAME).Result;

            container.HandleAsync(stringMessage, null).Wait();

            Assert.IsTrue(BlobReader.ListFilesAsync().Result.Count() == 0);
        }
Beispiel #5
0
        public void BigMessage_Going_To_File_In_Send()
        {
            BlobReader.DeleteFilesAsync().Wait();
            QueueReader.CleanQueueAsync(SERVICENAME).Wait();

            InvocationCounter.Instance.Reset();

            var container = new HandlersContainer(SERVICENAME);

            var message = new BigMessage();

            message.Data = new string('*', 66000);

            SendOnlyBus.SendAsync(message, SERVICENAME).Wait();

            var stringMessage = QueueReader.ReadOneMessageFromQueueAsync(SERVICENAME).Result;

            container.HandleAsync(stringMessage, null).Wait();

            Assert.IsTrue(InvocationCounter.Instance.Counter == 1);
        }