Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotBlockIfNoneOfTheBlockersBlock() throws CommandFailed, IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotBlockIfNoneOfTheBlockersBlock()
        {
            AdminCommand command = mock(typeof(AdminCommand));

            AdminCommand_Blocker falseBlocker = mock(typeof(AdminCommand_Blocker));

            when(falseBlocker.DoesBlock(any(), any())).thenReturn(false);
            when(falseBlocker.Explanation()).thenReturn("falseBlocker explanation");

            BlockerLocator blockerLocator = mock(typeof(BlockerLocator));

            when(blockerLocator.FindBlockers("command")).thenReturn(Arrays.asList(falseBlocker, falseBlocker, falseBlocker));

            (new AdminTool(CannedCommand("command", command), blockerLocator, new NullOutsideWorld(), false)).execute(null, null, "command", "the", "other", "args");
            verify(command).execute(new string[] { "the", "other", "args" });
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldBlockDumpIfABlockerSaysSo()
        internal virtual void ShouldBlockDumpIfABlockerSaysSo()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            AdminCommand command      = mock(typeof(AdminCommand));

            AdminCommand_Blocker blocker = mock(typeof(AdminCommand_Blocker));

            when(blocker.DoesBlock(any(), any())).thenReturn(true);
            when(blocker.Commands()).thenReturn(Collections.singleton("command"));
            when(blocker.Explanation()).thenReturn("the explanation");

            BlockerLocator blockerLocator = mock(typeof(BlockerLocator));

            when(blockerLocator.FindBlockers("command")).thenReturn(Collections.singletonList(blocker));

            (new AdminTool(CannedCommand("command", command), blockerLocator, outsideWorld, false)).execute(null, null, "command");

            verify(outsideWorld).stdErrLine("command failed: the explanation");
            verify(outsideWorld).exit(STATUS_ERROR);
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldBlockDumpIfOneBlockerOutOfManySaysSo()
        internal virtual void ShouldBlockDumpIfOneBlockerOutOfManySaysSo()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            AdminCommand command      = mock(typeof(AdminCommand));

            AdminCommand_Blocker trueBlocker = mock(typeof(AdminCommand_Blocker));

            when(trueBlocker.DoesBlock(any(), any())).thenReturn(true);
            when(trueBlocker.Explanation()).thenReturn("trueBlocker explanation");

            AdminCommand_Blocker falseBlocker = mock(typeof(AdminCommand_Blocker));

            when(falseBlocker.DoesBlock(any(), any())).thenReturn(false);
            when(falseBlocker.Explanation()).thenReturn("falseBlocker explanation");

            BlockerLocator blockerLocator = mock(typeof(BlockerLocator));

            when(blockerLocator.FindBlockers("command")).thenReturn(Arrays.asList(falseBlocker, trueBlocker, falseBlocker));

            (new AdminTool(CannedCommand("command", command), blockerLocator, outsideWorld, false)).execute(null, null, "command");

            verify(outsideWorld).stdErrLine("command failed: trueBlocker explanation");
            verify(outsideWorld).exit(STATUS_ERROR);
        }