示例#1
0
 public void Load_WhenInvokedWithDuplicateSelectors_Throws()
 {
     Assert.That(
         () => { systemUnderTest.Load(MockCommandGenerator.GenerateCommandCollectionWithDuplicateSelectors()); },
         Throws.InstanceOf <DuplicateCommandSelectorException>().With.Message
         .EqualTo("Cannot add 'T'. Command Selector values must be unique."));
 }
示例#2
0
 public void RegisterCommands_WhenInvokedWithInvalidData_DoesNotThrow()
 {
     Assert.DoesNotThrow(
         () =>
     {
         systemUnderTest.RegisterCommands(
             MockCommandGenerator.GenerateCommandCollectionWithDuplicateSelectors());
     });
 }
 public void SetUp()
 {
     validCommands = MockCommandGenerator.GenerateValidCommandCollection().ToList();
     processorMock = Substitute.For <ICommandLineProcessorService>();
     processorMock.ActiveCommand.Returns(x => activeCommandMock);
     processorMock.Settings = new CommandLineSettings {
         CommandPromptRoot = CommandRoot
     };
     activeCommandMock         = null;
     systemUnderTest           = new InputHandlerProvider();
     systemUnderTest.Processor = processorMock;
 }
示例#4
0
        public void RegisterCommands_WhenInvokedWithInvalidData_FiresErrorEventResetsStatus()
        {
            var       invalidCommands = MockCommandGenerator.GenerateCommandCollectionWithDuplicateSelectors();
            var       sourceError     = new Exception("Test Exception");
            Exception actualError     = null;

            systemUnderTest.CommandRegistrationError += (sender, args) => { actualError = args.Exception; };
            commandRepositoryMock.When(x => x.Load(invalidCommands)).Do(x => throw sourceError);

            systemUnderTest.RegisterCommands(invalidCommands);

            Assert.AreSame(actualError, sourceError);
            Assert.That(systemUnderTest.Status, Is.EqualTo(CommandLineStatus.WaitingForCommandRegistration));
        }
示例#5
0
 public void SetUp()
 {
     validCommandCollection    = MockCommandGenerator.GenerateValidCommandCollection().ToList();
     commandRepositoryMock     = Substitute.For <ICommandRepositoryService>();
     commandPathCalculatorMock = Substitute.For <ICommandPathCalculator>();
     commandContextMock        = Substitute.For <ICommandContext>();
     commandContextFactoryMock = Substitute.For <Func <ICommandContext> >();
     commandContextFactoryMock().Returns(commandContextMock);
     commandHistoryServiceMock = Substitute.For <ICommandHistoryService>();
     systemUnderTest           = new CommandLineProcessorProvider(
         commandRepositoryMock,
         commandPathCalculatorMock,
         commandContextFactoryMock,
         commandHistoryServiceMock);
 }
示例#6
0
 public void SetUp()
 {
     systemUnderTest = new CommandRepositoryProvider();
     mockCommandList = new List <ICommand>(MockCommandGenerator.GenerateValidCommandCollection());
 }