Esempio n. 1
0
        public void ThrowArgumentException_WhenEngineIdParameterIsEmpty()
        {
            // Arrange
            var logFileParserEngineManager = new Mock <ILogFileParserEngineManager>();
            var commandJsonConvertProvider = new Mock <ICommandEnumerationJsonConvertProvider>();

            var logFileParserHubService = new LogFileParserHubService(logFileParserEngineManager.Object, commandJsonConvertProvider.Object);

            var engineId          = string.Empty;
            var serializedCommand = "serialized command";

            // Act & Assert
            Assert.That(
                () => logFileParserHubService.SendCommand(engineId, serializedCommand),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains(nameof(engineId)));
        }
Esempio n. 2
0
        public void ThrowArgumentException_WhenICommandJsonConvertProviderIsUnableToDeserializeInput()
        {
            // Arrange
            var logFileParserEngineManager = new Mock <ILogFileParserEngineManager>();
            var commandJsonConvertProvider = new Mock <ICommandEnumerationJsonConvertProvider>();

            var logFileParserHubService = new LogFileParserHubService(logFileParserEngineManager.Object, commandJsonConvertProvider.Object);

            var deserializedCommand = new Mock <ICommand>();

            commandJsonConvertProvider.Setup(p => p.DeserializeCommand(It.IsAny <string>())).Returns <ICommand>(null);

            var    engineId          = "any engine id";
            string serializedCommand = null;

            // Act & Assert
            Assert.That(
                () => logFileParserHubService.SendCommand(engineId, serializedCommand),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains(nameof(serializedCommand)));
        }
Esempio n. 3
0
        public void InvokeILogFileParserEngineManager_EnqueueCommandToEngineWithIdMethodOnceWithCorrectParameters()
        {
            // Arrange
            var logFileParserEngineManager = new Mock <ILogFileParserEngineManager>();
            var commandJsonConvertProvider = new Mock <ICommandEnumerationJsonConvertProvider>();

            var logFileParserHubService = new LogFileParserHubService(logFileParserEngineManager.Object, commandJsonConvertProvider.Object);

            var deserializedCommand = new Mock <ICommand>();

            commandJsonConvertProvider.Setup(p => p.DeserializeCommand(It.IsAny <string>())).Returns(deserializedCommand.Object);

            var engineId          = "any engine id";
            var serializedCommand = "serialized command";

            // Act
            logFileParserHubService.SendCommand(engineId, serializedCommand);

            // Assert
            logFileParserEngineManager.Verify(m => m.EnqueueCommandToEngineWithId(engineId, deserializedCommand.Object), Times.Once);
        }