コード例 #1
0
 public void RemovingNotExistingCommandShouldThrow()
 {
     BasicUIRenderer basicUIRenderer = new ConsoleUIRenderer();
     var command = new ExitCommand(basicUIRenderer, "test");
     var mockedCommandComposer = new Mock<CommandComposer>(basicUIRenderer);
     mockedCommandComposer.Setup(x => x.Execute()).Throws(new Exception());
     mockedCommandComposer.Object.AddCommand(command);
 }
コード例 #2
0
 public void ExecuteCommandShouldNotThrow()
 {
     BasicUIRenderer basicUIRenderer = new ConsoleUIRenderer();
     var command = new ExitCommand(basicUIRenderer, "test");
     var mockedCommandComposer = new Mock<CommandComposer>(basicUIRenderer);
     mockedCommandComposer.Object.AddCommand(command);
     mockedCommandComposer.Object.Execute();
     mockedCommandComposer.Verify(x => x.Execute(), Times.Once());
 }
コード例 #3
0
 public void AddingAndRemovingCommandShouldResultInCountOfAvailableCommandsEqualToZero()
 {
     BasicUIRenderer basicUIRenderer = new ConsoleUIRenderer();
     var command = new ExitCommand(basicUIRenderer, "test");
     var mockedCommandComposer = new Mock<CommandComposer>(basicUIRenderer);
     mockedCommandComposer.Object.AddCommand(command);
     mockedCommandComposer.Setup(x => x.Execute());
     mockedCommandComposer.Object.RemoveExecutedCommand();
     mockedCommandComposer.Setup(x => x.Execute()).Throws(new Exception());
 }