コード例 #1
0
        public void WriteSomeFiles()
        {
            var directory = new DirectoryInfo(tempDirectory);

            foreach (var file in directory.EnumerateFiles())
            {
                file.Delete();
            }

            var properties = new MessageProperties();
            var info       = Helper.CreateMessageRecievedInfo();
            var writer     = new FileMessageWriter();
            var messages   = new List <HosepipeMessage>
            {
                new HosepipeMessage("This is message one", properties, info),
                new HosepipeMessage("This is message two", properties, info),
                new HosepipeMessage("This is message three", properties, info)
            };

            var parameters = new QueueParameters
            {
                QueueName       = "Queue EasyNetQ_Tests_TestAsyncRequestMessage:EasyNetQ_Tests_Messages",
                MessageFilePath = tempDirectory
            };

            writer.Write(messages, parameters);

            foreach (var file in directory.EnumerateFiles())
            {
                Console.Out.WriteLine("{0}", file.Name);
            }
        }
コード例 #2
0
        public void WriteSomeFiles()
        {
            var directory = new DirectoryInfo(tempDirectory);
            foreach (var file in directory.EnumerateFiles())
            {
                file.Delete();
            }

            var properties = new MessageProperties();
            var info = Helper.CreateMessageRecievedInfo();
            var writer = new FileMessageWriter();
            var messages = new List<HosepipeMessage>
            {
                new HosepipeMessage("This is message one", properties, info),
                new HosepipeMessage("This is message two", properties, info),
                new HosepipeMessage("This is message three", properties, info)
            };

            var parameters = new QueueParameters
            {
                QueueName = "Queue EasyNetQ_Tests_TestAsyncRequestMessage:EasyNetQ_Tests_Messages",
                MessageFilePath = tempDirectory
            };

            writer.Write(messages, parameters);

            foreach (var file in directory.EnumerateFiles())
            {
                Console.Out.WriteLine("{0}", file.Name);
            }
        }
コード例 #3
0
        public void Should_remove_invalid_file_chars()
        {
            const string originalQueueName          = @"\A/B:C*D?E""F<G>H|I";
            const string expectedSanitisedQueueName = @"_A_B_C_D_E_F_G_H_I";

            var sanitisedQueueName = FileMessageWriter.SanitiseQueueName(originalQueueName);

            sanitisedQueueName.ShouldEqual(expectedSanitisedQueueName);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //Poor man's DI - create the writer and pass it to the salutation. No container is used.
            //IMessageWriter writer = new ConsoleMessageWriter(); //create concrete writer(Console)
            IMessageWriter writer = new FileMessageWriter();    //create concrete writer(File)
            //IMessageWriter writer = new DataBaseWriter();         //create concrete writer(DataBase)
            var salutation = new Salutation(writer);            //Inject it as dependency

            salutation.Exclaim();                               //Call the action
        }
コード例 #5
0
        public void WriteSomeFiles()
        {
            var writer = new FileMessageWriter();
            var messages = new List<string>
            {
                "This is message one",
                "This is message two",
                "This is message three"
            };

            var parameters = new QueueParameters
            {
                QueueName = "TheNameOfTheQueue",
                MessageFilePath = @"C:\temp\MessageOutput"
            };

            writer.Write(messages, parameters);
        }
コード例 #6
0
        public void WriteSomeFiles()
        {
            var writer   = new FileMessageWriter();
            var messages = new List <string>
            {
                "This is message one",
                "This is message two",
                "This is message three"
            };

            var parameters = new QueueParameters
            {
                QueueName       = "Queue EasyNetQ_Tests_TestAsyncRequestMessage:EasyNetQ_Tests_Messages",
                MessageFilePath = @"C:\temp\MessageOutput"
            };

            writer.Write(messages, parameters);
        }
コード例 #7
0
        public void WriteSomeFiles()
        {
            var writer = new FileMessageWriter();
            var messages = new List<string>
            {
                "This is message one",
                "This is message two",
                "This is message three"
            };

            var parameters = new QueueParameters
            {
                QueueName = "Queue EasyNetQ_Tests_TestAsyncRequestMessage:EasyNetQ_Tests_Messages",
                MessageFilePath = @"C:\temp\MessageOutput"
            };

            writer.Write(messages, parameters);
        }