コード例 #1
0
        /// <summary>
        /// Facade class - Process and orchestrate other service implementation
        /// </summary>
        /// <param name="input">Long Int</param>
        /// <returns>Service Codes - Success, Invalid Input, Error</returns>
        public ServiceCode Process(long input)
        {
            try
            {
                _logger.LogInformation("Processing input..");
                _logger.LogDebug($"Processing value - {input}");

                var numbers = _numberService.GetValues(input);

                if (numbers.Count > 0)
                {
                    var gridOutput = _operatorService.Execute(numbers);

                    if (!string.IsNullOrEmpty(gridOutput))
                    {
                        _printService.Print(gridOutput);
                        _logger.LogInformation("Processing Complete");
                        return(ServiceCode.SUCCESS);
                    }

                    _logger.LogInformation("Error while generating table, Empty response.");
                    return(ServiceCode.APPLICATION_ERROR);
                }

                _logger.LogInformation("Invalid Input. Nothing to process..");
                return(ServiceCode.INVALID_INPUT);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while processing.. Check exception details");
                return(ServiceCode.SYSTEM_ERROR);
            }
        }
コード例 #2
0
        public void ValidInput_TableNotGenerated()
        {
            //Arrange
            _operatorService = new Multiply(_mockLogger.Object);

            //Act
            var output = _operatorService.Execute(new List <long> {
            });

            //Assert
            Assert.Null(output);
        }
コード例 #3
0
        public void ValidInput_TableGenerated()
        {
            //Arrange
            _operatorService = new Multiply(_mockLogger.Object);

            //Act
            var output = _operatorService.Execute(new List <long> {
                2
            });

            //Assert
            Assert.Contains("4", output);
            Assert.Contains("6", output);
            Assert.Contains("8", output);
            Assert.Contains("20", output);
        }