Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void eventShouldBubbleUp()
        public virtual void EventShouldBubbleUp()
        {
            Monitors  parent         = new Monitors();
            MyMonitor parentListener = mock(typeof(MyMonitor));

            parent.AddMonitorListener(parentListener);

            Monitors  child         = new Monitors(parent);
            MyMonitor childListener = mock(typeof(MyMonitor));

            child.AddMonitorListener(childListener);

            // Calls on monitors from parent should not reach child listeners
            MyMonitor parentMonitor = parent.NewMonitor(typeof(MyMonitor));

            parentMonitor.AVoid();
            verify(parentListener, times(1)).aVoid();
            verifyZeroInteractions(childListener);

            // Calls on monitors from child should reach both listeners
            MyMonitor childMonitor = child.NewMonitor(typeof(MyMonitor));

            childMonitor.AVoid();
            verify(parentListener, times(2)).aVoid();
            verify(childListener, times(1)).aVoid();
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideNoOpDelegate()
        public virtual void ShouldProvideNoOpDelegate()
        {
            // Given
            Monitors monitors = new Monitors();

            // When
            MyMonitor monitor = monitors.NewMonitor(typeof(MyMonitor));

            // Then those should be no-ops
            monitor.AVoid();
            monitor.TakesArgs("ha", 12, new object());
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRegister()
        public virtual void ShouldRegister()
        {
            // Given
            Monitors monitors = new Monitors();

            MyMonitor listener = mock(typeof(MyMonitor));
            MyMonitor monitor  = monitors.NewMonitor(typeof(MyMonitor));
            object    obj      = new object();

            // When
            monitors.AddMonitorListener(listener);
            monitor.AVoid();
            monitor.TakesArgs("ha", 12, obj);

            // Then
            verify(listener).aVoid();
            verify(listener).takesArgs("ha", 12, obj);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUnregister()
        public virtual void ShouldUnregister()
        {
            // Given
            Monitors monitors = new Monitors();

            MyMonitor listener = mock(typeof(MyMonitor));
            MyMonitor monitor  = monitors.NewMonitor(typeof(MyMonitor));
            object    obj      = new object();

            monitors.AddMonitorListener(listener);

            // When
            monitors.RemoveMonitorListener(listener);
            monitor.AVoid();
            monitor.TakesArgs("ha", 12, obj);

            // Then
            verifyNoMoreInteractions(listener);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRespectTags()
        public virtual void ShouldRespectTags()
        {
            // Given
            Monitors monitors = new Monitors();

            MyMonitor listener    = mock(typeof(MyMonitor));
            MyMonitor monitorTag1 = monitors.NewMonitor(typeof(MyMonitor), "tag1");
            MyMonitor monitorTag2 = monitors.NewMonitor(typeof(MyMonitor), "tag2");

            // When
            monitors.AddMonitorListener(listener, "tag2");

            // Then
            monitorTag1.AVoid();
            verifyZeroInteractions(listener);
            monitorTag2.AVoid();
            verify(listener, times(1)).aVoid();
            verifyNoMoreInteractions(listener);
        }