public void UnknownValueIsNotAffectedBySerializing()
        {
            var value    = "asdfasoifewq34-93-24;te/,;t[s54;366]2==IUW_935 rt t\\q rs  \n\r asfp842-36";
            var property = new SgfUnknownValue(value);

            Assert.AreEqual(value, property.Serialize());
        }
        public void UnknownValueIsNotAffectedByParsing()
        {
            var value    = "asdfasoifewq34-93-24;te/,;t[s54;366]2==IUW_935 rt t\\q rs  \n\r asfp842-36";
            var property = (SgfUnknownValue)SgfUnknownValue.Parse(value);

            Assert.AreEqual(value, property.Value);
        }
        public static SgfProperty ParseValuesAndCreate(string identifier, params string[] serializedValues)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }
            if (serializedValues == null)
            {
                throw new ArgumentNullException(nameof(serializedValues));
            }
            var knownProperty = SgfKnownProperties.Get(identifier);

            if (knownProperty != null)
            {
                //parse as known
                if (knownProperty.ValueMultiplicity == SgfValueMultiplicity.None)
                {
                    if (serializedValues.Length > 0)
                    {
                        if (serializedValues.Length != 1 ||
                            serializedValues[0] != "")
                        {
                            throw new SgfParseException($"Property {identifier} has none multiplicity and can't be given values.");
                        }
                    }
                    return(new SgfProperty(identifier));
                }
                if (knownProperty.ValueMultiplicity == SgfValueMultiplicity.Single)
                {
                    if (serializedValues.Length != 1)
                    {
                        throw new SgfParseException($"Property {identifier} has single multiplicity and must be given exactly one value.");
                    }
                    return(new SgfProperty(identifier, knownProperty.Parser(serializedValues[0])));
                }
                if (knownProperty.ValueMultiplicity == SgfValueMultiplicity.EList)
                {
                    if (serializedValues.Length == 1 && serializedValues[0] == "")
                    {
                        return(new SgfProperty(identifier));
                    }
                }
                //default - multiple values
                return(new SgfProperty(identifier, serializedValues.Select(v => knownProperty.Parser(v)).ToArray()));
            }
            else
            {
                var values = serializedValues.Select(
                    v => (ISgfPropertyValue)SgfUnknownValue.Parse(v)
                    ).ToArray();
                return(new SgfProperty(identifier, values));
            }
        }
        public void UnkownValueIdentifiesItselfCorrectly()
        {
            var value = new SgfUnknownValue("asdf");

            Assert.AreEqual(SgfValueType.Unknown, value.ValueType);
        }
        public void ValidUnknownValueParseReturnsInstanceOfUnknown()
        {
            var result = SgfUnknownValue.Parse("someValue");

            Assert.IsTrue(result is SgfUnknownValue);
        }
 public void SgfUnknownPropertyValueParsingDoesNotAcceptNullValue()
 {
     var result = SgfUnknownValue.Parse(null);
 }
 public void SgfUnknownPropertyValueDoesNotAcceptNullValue()
 {
     var property = new SgfUnknownValue(null);
 }