public void ThrowArgumentNullException_WhenICommandUtilizationStrategyIsNull() { // Arrange var commandParsingStrategy = new Mock<ICommandParsingStrategy>(); ICommandUtilizationStrategy commandUtilizationStrategy = null; var logFilePathDiscoveryStrategy = new Mock<ILogFilePathDiscoveryStrategy>(); var fileReaderAutoResetEventFactory = new Mock<IFileReaderAutoResetEventFactory>(); var fileReaderFileSystemWatcherFactory = new Mock<IFileReaderFileSystemWatcherFactory>(); var fileReaderInputProviderFactory = new Mock<IFileReaderInputProviderFactory>(); // Act & Assert Assert.That( () => new LogFileReaderEngine(commandParsingStrategy.Object, commandUtilizationStrategy, logFilePathDiscoveryStrategy.Object, fileReaderAutoResetEventFactory.Object, fileReaderFileSystemWatcherFactory.Object, fileReaderInputProviderFactory.Object), Throws.InstanceOf<ArgumentNullException>().With.Message.Contains(nameof(ICommandUtilizationStrategy))); }
public LogFileReaderEngine(ICommandParsingStrategy commandParsingStrategy, ICommandUtilizationStrategy commandUtilizationStrategy, ILogFilePathDiscoveryStrategy logFilePathDiscoveryStrategy, IFileReaderAutoResetEventFactory fileReaderAutoResetEventFactory, IFileReaderFileSystemWatcherFactory fileReaderFileSystemWatcherFactory, IFileReaderInputProviderFactory fileReaderInputProviderFactory) { Guard.WhenArgument(commandParsingStrategy, nameof(ICommandParsingStrategy)).IsNull().Throw(); Guard.WhenArgument(commandUtilizationStrategy, nameof(ICommandUtilizationStrategy)).IsNull().Throw(); Guard.WhenArgument(logFilePathDiscoveryStrategy, nameof(ILogFilePathDiscoveryStrategy)).IsNull().Throw(); Guard.WhenArgument(fileReaderAutoResetEventFactory, nameof(IFileReaderAutoResetEventFactory)).IsNull().Throw(); Guard.WhenArgument(fileReaderFileSystemWatcherFactory, nameof(IFileReaderFileSystemWatcherFactory)).IsNull().Throw(); Guard.WhenArgument(fileReaderInputProviderFactory, nameof(IFileReaderInputProviderFactory)).IsNull().Throw(); this.commandParsingStrategy = commandParsingStrategy; this.commandUtilizationStrategy = commandUtilizationStrategy; this.logFilePathDiscoveryStrategy = logFilePathDiscoveryStrategy; this.fileReaderAutoResetEventFactory = fileReaderAutoResetEventFactory; this.fileReaderFileSystemWatcherFactory = fileReaderFileSystemWatcherFactory; this.fileReaderInputProviderFactory = fileReaderInputProviderFactory; }