コード例 #1
0
        List<Tuple<bool, Type, string, string>> AssertEventNames(RabbitMqMessageQueue queue, IEnumerable<Tuple<Type, string>> eventsAndExpectedEventNames)
        {
            return eventsAndExpectedEventNames
                .Select(t =>
                    {
                        var eventType = t.Item1;
                        var expectedEventName = t.Item2;

                        var eventName = queue.GetEventName(eventType);

                        return eventName == expectedEventName
                                   ? Tuple.Create(true, eventType, eventName, expectedEventName)
                                   : Tuple.Create(false, eventType, eventName, expectedEventName);
                    })
                .ToList();
        }
コード例 #2
0
        public void TestPerformanceOfPrettyEventNameGeneration(int count)
        {
            var queue = new RabbitMqMessageQueue(ConnectionString, "test.eventnames");
            var eventTypes = new List<Type>
                                 {
                                     typeof (string),
                                     typeof (List<string>),
                                     typeof (List<Tuple<string, int, int>>),
                                     typeof (Tuple<List<Tuple<string, int, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, int>>>>>>>),
                                     typeof (Tuple<Tuple<List<Tuple<string, int, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, int>>>>>>,
                                     Tuple<List<Tuple<string, int, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, int>>>>>>,
                                     Tuple<List<Tuple<string, int, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, int>>>>>>,
                                     Tuple<List<Tuple<string, int, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, Tuple<string, int, int>>>>>>>>>>>),
                                 };

            var elapsed = eventTypes.Select(t =>
                {
                    var stopwatch = Stopwatch.StartNew();
                    count.Times(() => queue.GetEventName(t));
                    return Tuple.Create(queue.GetEventName(t), stopwatch.Elapsed);
                });

            Console.WriteLine(string.Join(Environment.NewLine, elapsed.Select(t => string.Format(@"    {0:0.0}   {1}", t.Item2.TotalSeconds, t.Item1))));
        }