コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSkipOccupiedPorts()
        internal virtual void ShouldSkipOccupiedPorts()
        {
            PortProbe    portProbe    = mock(typeof(PortProbe));
            PortProvider portProvider = new SimplePortProvider(portProbe, 40);

            when(portProbe.IsOccupied(40)).thenReturn(false);
            when(portProbe.IsOccupied(41)).thenReturn(false);
            when(portProbe.IsOccupied(42)).thenReturn(true);
            when(portProbe.IsOccupied(43)).thenReturn(false);
            assertThat(portProvider.GetNextFreePort("foo"), @is(40));
            assertThat(portProvider.GetNextFreePort("foo"), @is(41));
            assertThat(portProvider.GetNextFreePort("foo"), @is(43));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSkipOccupiedPorts()
        internal virtual void ShouldSkipOccupiedPorts()
        {
            PortRepository portRepository = mock(typeof(PortRepository));
            PortProbe      portProbe      = mock(typeof(PortProbe));
            PortProvider   portProvider   = new CoordinatingPortProvider(portRepository, portProbe);

            when(portRepository.ReserveNextPort("foo")).thenReturn(40, 41, 42, 43);
            when(portProbe.IsOccupied(40)).thenReturn(false);
            when(portProbe.IsOccupied(41)).thenReturn(false);
            when(portProbe.IsOccupied(42)).thenReturn(true);
            when(portProbe.IsOccupied(43)).thenReturn(false);
            assertThat(portProvider.GetNextFreePort("foo"), @is(40));
            assertThat(portProvider.GetNextFreePort("foo"), @is(41));
            assertThat(portProvider.GetNextFreePort("foo"), @is(43));
        }