コード例 #1
0
        public void CheckIfTypeIsCommonStructAndReturnObject_IsValidType_ReturnsParsedValue()
        {
            // Arrange
            Type numberType = typeof(int);

            // Act
            var result = _target.CheckIfTypeIsCommonStructAndReturnObject(numberType, "1");

            // Assert
            result.Should().BeOfType <int>();
        }
コード例 #2
0
        /// <summary>
        /// Handles structs, creates instance of struct or just parses input to type, depends on struct
        /// </summary>
        /// <param name="type">Type of struct</param>
        /// <param name="userInput">User input</param>
        /// <returns>Returns new struct of same type with user input in it, or parsed user input to provided type</returns>
        private object HandleStructs(Type type, string userInput)
        {
            var structWithArguments = _moduleStructHandler.CheckIfStructMustHaveArgumentsAndReturnObject(type, userInput);

            if (structWithArguments == null)
            {
                return(_moduleStructHandler.CheckIfTypeIsCommonStructAndReturnObject(type, userInput));
            }

            return(structWithArguments);
        }