コード例 #1
0
        public void Should_detect_assertion()
        {
            var testExecutionMethodBeginClientEvent = new TestExecutionMethodBeginClientEvent
                                                          {
                                                              NamespaceName = "a",
                                                              ClassName = "b",
                                                              MethodName = "c",
                                                          };
            var dialogAssertionServerEvent = new DialogAssertionServerEvent(DialogType.Assert)
                                                 {
                                                     Message = "at b.c",
                                                 };
            var dialogAssertionMatchmaker = new DialogAssertionMatchmaker();
            var testExecutionMethod = new TestExecutionMethodPassedClientEvent
                                          {
                                              NamespaceName = "a",
                                              ClassName = "b",
                                              MethodName = "c",
                                          };
            bool match = false;

            dialogAssertionMatchmaker.HandleMethodBeginClientEvent(testExecutionMethodBeginClientEvent);
            dialogAssertionMatchmaker.AddAssertionHandler(dialogAssertionServerEvent, item =>
            {
                match = true;
            });

            dialogAssertionMatchmaker.WasEventAlreadyClosed(testExecutionMethod).ShouldBeTrue();
            match.ShouldBeTrue();
        }
コード例 #2
0
        public void If_assettion_happens_before_begin_test_event_arrives_should_match()
        {
            var testExecutionMethodBeginClientEvent = new TestExecutionMethodBeginClientEvent
            {
                NamespaceName = "a",
                ClassName     = "b",
                MethodName    = "c",
            };
            var dialogAssertionServerEvent = new DialogAssertionServerEvent(DialogType.Assert)
            {
                Message = "at b.c",
            };
            var dialogAssertionMatchmaker = new DialogAssertionMatchmaker();
            var testExecutionMethod       = new TestExecutionMethodPassedClientEvent
            {
                NamespaceName = "a",
                ClassName     = "b",
                MethodName    = "c",
            };
            bool match = false;


            dialogAssertionMatchmaker.AddAssertionHandler(dialogAssertionServerEvent, item =>
            {
                match = true;
            });
            dialogAssertionMatchmaker.HandleMethodBeginClientEvent(testExecutionMethodBeginClientEvent);


            dialogAssertionMatchmaker.WasEventAlreadyClosed(testExecutionMethod).ShouldBeTrue();
            match.ShouldBeTrue();
        }
コード例 #3
0
 public void HandleMethodBeginClientEvent(TestExecutionMethodBeginClientEvent message)
 {
     if (_dialogAssertionEventsWithHandlers.Any(w => w.Key.Message.Contains(message.MethodName)))
     {
         var x = _dialogAssertionEventsWithHandlers.First(w => w.Key.Message.Contains(message.MethodName));
         _completedMessage.Add(message);
         x.Value(message);
     }
 }
コード例 #4
0
 public void HandleMethodBeginClientEvent(TestExecutionMethodBeginClientEvent message)
 {
     if (_dialogAssertionEventsWithHandlers.Any(w => w.Key.Message.Contains(message.MethodName)))
     {
         var x = _dialogAssertionEventsWithHandlers.First(w => w.Key.Message.Contains(message.MethodName));
         _completedMessage.Add(message);
         x.Value(message);
     }
 }
コード例 #5
0
        public void Handle(TestExecutionMethodBeginClientEvent message)
        {
            // TODO: For some reason this is triggered AFTER the method is run, so the test timings are incorrect
            var testMethod = GetTestMethod(message.FullMethodName);

            if (testMethod != null)
            {
                testMethod.Node.NotifyStarting();
            }
        }
コード例 #6
0
        public ClientEvent Translate(LogMessage message)
        {
            var testMethod   = (ITestMethod)message.Decorators[UnitTestLogDecorator.TestMethodMetadata];
            var clientEventX = new TestExecutionMethodBeginClientEvent
            {
                Started = DateTime.Now,
            };

            clientEventX.AssignTestExecutionMethodInfo(testMethod);
            return(clientEventX);
        }
コード例 #7
0
        public void HandleMethodBeginClientEvent(TestExecutionMethodBeginClientEvent message)
        {
            var searchFor = GetItemToSearchFor(message);

            if (_dialogAssertionEventsWithHandlers.Any(w => w.Key.Message.Contains(searchFor)))
            {
                var x = _dialogAssertionEventsWithHandlers.First(w => w.Key.Message.Contains(searchFor));
                MarkItMatched(message, x.Value);
            }
            else
            {
                _notHandledYet.Add(message);
            }
        }
コード例 #8
0
        public void HandleMethodBeginClientEvent(TestExecutionMethodBeginClientEvent message)
        {
            var searchFor = GetItemToSearchFor(message);

            if (_dialogAssertionEventsWithHandlers.Any(w => w.Key.Message.Contains(searchFor)))
            {
                var x = _dialogAssertionEventsWithHandlers.First(w => w.Key.Message.Contains(searchFor));
                MarkItMatched(message, x.Value);
            }
            else
            {
                _notHandledYet.Add(message);
            }
        }
コード例 #9
0
 public void AddBeginEvent(TestExecutionMethodBeginClientEvent clientEvent)
 {
     lock (_sync)
     {
         if (_awaitingForAMatch.ContainsKey(clientEvent.FullMethodName))
         {
             Action a = _awaitingForAMatch[clientEvent.FullMethodName];
             if (a != null)
             {
                 a();
             }
             _awaitingForAMatch.Remove(clientEvent.FullMethodName);
         }
         else
         {
             _awaitingForAMatch.Add(clientEvent.FullMethodName, null);
         }
     }
 }
コード例 #10
0
        public void Handle(TestExecutionMethodBeginClientEvent message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (_beginEventsAlreadyFired.Contains(message.FullMethodName.GetHashCode()))
            {
                _logger.Debug(message.WriteDebug());

                return;
            }

            _beginEventsAlreadyFired.Add(message.FullMethodName.GetHashCode());

            //_logger.Debug("Handle - TestExecutionMethodBeginClientEvent - {0}".FormatWith(message.FullMethodName));
            _dialogAssertionMessageMatchmaker.HandleMethodBeginClientEvent(message);

            _eventMatchMacker.AddBeginEvent(message);
        }
コード例 #11
0
 private void MarkItMatched(TestExecutionMethodBeginClientEvent message, Action <TestExecutionMethodBeginClientEvent> action)
 {
     _completedMessage.Add(message);
     action(message);
 }
コード例 #12
0
 private static string GetItemToSearchFor(TestExecutionMethodBeginClientEvent message)
 {
     return(message.ClassName + "." + message.MethodName);
 }
コード例 #13
0
 private void MarkItMatched(TestExecutionMethodBeginClientEvent message, Action<TestExecutionMethodBeginClientEvent> action)
 {
     _completedMessage.Add(message);
     action(message);
 }
コード例 #14
0
 private static string GetItemToSearchFor(TestExecutionMethodBeginClientEvent message)
 {
     return message.ClassName + "." + message.MethodName;
 }