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.")); }
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; }
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)); }
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); }
public void SetUp() { systemUnderTest = new CommandRepositoryProvider(); mockCommandList = new List <ICommand>(MockCommandGenerator.GenerateValidCommandCollection()); }