示例#1
0
        public void ItShouldParseCustomPrimitiveValueTypes()
        {
            var data   = this.NewInstance();
            var parsed = data.Parse();

            Assert.AreEqual(parsed.SomeParsedInt, ParsedInt.Parse(data.SomeParsedInt));
            Assert.AreEqual(parsed.OptionalParsedInt, ParsedInt.Parse(data.OptionalParsedInt.Value));
        }
示例#2
0
        public static bool TryParse(int value, out ParsedInt @object, out IReadOnlyCollection <string> errorMessages)
        {
            var errorMessageList = new List <string>();

            errorMessages = errorMessageList;

            if (value < 0)
            {
                errorMessageList.Add("Must be positive");
            }

            if (errorMessageList.Count > 0)
            {
                @object = null;
                return(false);
            }

            @object = new ParsedInt
            {
                Value = value
            };

            return(true);
        }